22 |
echo " [def=\"$OUTDIR\"]" |
echo " [def=\"$OUTDIR\"]" |
23 |
echo " (-t |-tempd )DIR use temporary directory DIR" |
echo " (-t |-tempd )DIR use temporary directory DIR" |
24 |
echo " [def=\"$TEMPDIR\"]" |
echo " [def=\"$TEMPDIR\"]" |
25 |
|
echo " (-a |-addr )ADDR send e-mail to ADDR if Error" |
26 |
|
echo " [def='"$ADDRERR"']" |
27 |
echo |
echo |
28 |
exit 1 |
exit 1 |
29 |
} |
} |
30 |
|
|
31 |
# defaults |
# defaults |
32 |
INDIR="/u/edhill/Mail/MITgcm-test" |
INDIR="/u/u2/jmc/Mail/MITgcm-test" |
33 |
OUTDIR= |
OUTDIR="/u/u0/httpd/html/testing/results/"`date +%Y`"_"`date +%m` |
34 |
TEMPDIR=./ptmp |
TEMPDIR=./ptmp |
35 |
MUNPACK=/u/edhill/local/bin/munpack |
MUNPACK=/u/u2/jmc/testing/tools_mpack/munpack |
36 |
|
ADDRERR= |
37 |
PRT=1 |
PRT=1 |
38 |
|
|
39 |
# Parse options |
# Parse options |
72 |
ac_prev=TEMPDIR ;; |
ac_prev=TEMPDIR ;; |
73 |
--tempd=* | -tempd=* | --t=* | -t=*) |
--tempd=* | -tempd=* | --t=* | -t=*) |
74 |
TEMPDIR=$ac_optarg ;; |
TEMPDIR=$ac_optarg ;; |
75 |
|
-a | --aa | -addr | --addr) |
76 |
|
ac_prev=ADDRERR ;; |
77 |
|
-a=* | --aa=* | -addr=* | --addr=*) |
78 |
|
ADDRERR=$ac_optarg ;; |
79 |
|
|
80 |
*) |
*) |
81 |
# copy the file list to FL_# |
# copy the file list to FL_# |
87 |
|
|
88 |
done |
done |
89 |
|
|
|
if test "x$OUTDIR" = x ; then |
|
|
OUTDIR="/u/u0/httpd/html/testing/results/"`date +%Y`"_"`date +%m` |
|
|
fi |
|
90 |
if test ! -e $OUTDIR ; then |
if test ! -e $OUTDIR ; then |
91 |
mkdir $OUTDIR |
mkdir $OUTDIR |
92 |
RETVAL=$? |
RETVAL=$? |
99 |
fi |
fi |
100 |
|
|
101 |
all_files=`ls -1 $INDIR` |
all_files=`ls -1 $INDIR` |
102 |
nb_files=`echo $all_files | grep -c '^msg\.'` |
nb_files=`echo "$all_files" | grep -c '^msg\.'` |
103 |
|
|
104 |
if test $PRT = 1 ; then |
if test $PRT = 1 ; then |
105 |
echo "Using OUTDIR=\"$OUTDIR\"" |
echo "Using OUTDIR=\"$OUTDIR\"" |
107 |
echo -n "Unpacking the emails ..." |
echo -n "Unpacking the emails ..." |
108 |
elif test $nb_files != 0 ; then |
elif test $nb_files != 0 ; then |
109 |
echo "Unpacking $nb_files emails from '$INDIR' to '$OUTDIR'" |
echo "Unpacking $nb_files emails from '$INDIR' to '$OUTDIR'" |
110 |
|
if test "x$ADDRERR" != x ; then |
111 |
|
echo " (send msg to '$ADDRERR' if Error)" |
112 |
|
fi |
113 |
if test $PRT = 2 ; then echo -n " dir:" ; fi |
if test $PRT = 2 ; then echo -n " dir:" ; fi |
114 |
fi |
fi |
115 |
|
|
124 |
grep "Content-Type: message/partial" $INDIR"/"$file > /dev/null 2>&1 |
grep "Content-Type: message/partial" $INDIR"/"$file > /dev/null 2>&1 |
125 |
RETVAL=$? |
RETVAL=$? |
126 |
if test "x$RETVAL" = x0 ; then |
if test "x$RETVAL" = x0 ; then |
127 |
continue |
if test "x$ADDRERR" != x ; then |
128 |
|
echo "parsing email error" > tmp.$$ |
129 |
|
echo 'grep "Content-Type: message/partial" returns error:' $RETVAL >> tmp.$$ |
130 |
|
ls -l $INDIR"/"$file >> tmp.$$ |
131 |
|
mail -s 'parse_emails err_1' $ADDRERR < tmp.$$ |
132 |
|
rm -f tmp.$$ |
133 |
|
fi |
134 |
|
mv -f $INDIR"/"$file $INDIR"/../fail2process/"$file |
135 |
|
continue |
136 |
fi |
fi |
137 |
|
|
138 |
# munpack |
# munpack |
139 |
mun=`( cd $TEMPDIR ; $MUNPACK $file | cut -d ' ' -f 1 | head -1 )` |
mun=`( cd $TEMPDIR ; $MUNPACK $file | cut -d ' ' -f 1 | head -1 )` |
140 |
RETVAL=$? |
RETVAL=$? |
141 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
142 |
continue |
if test "x$ADDRERR" != x ; then |
143 |
|
echo "parsing email error" > tmp.$$ |
144 |
|
echo "$MUNPACK $file returns error: $RETVAL" >> tmp.$$ |
145 |
|
ls -l $INDIR"/"$file >> tmp.$$ |
146 |
|
mail -s 'parse_emails err_2' $ADDRERR < tmp.$$ |
147 |
|
rm -f tmp.$$ |
148 |
|
fi |
149 |
|
mv -f $INDIR"/"$file $INDIR"/../fail2process/"$file |
150 |
|
continue |
151 |
fi |
fi |
152 |
|
|
153 |
# un-tar |
# un-tar |
154 |
( cd $TEMPDIR ; tar -xzvf $mun > out ) |
( cd $TEMPDIR ; tar -xzvf $mun > out ) |
155 |
RETVAL=$? |
RETVAL=$? |
156 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
157 |
continue |
if test "x$ADDRERR" != x ; then |
158 |
|
echo "parsing email error" > tmp.$$ |
159 |
|
echo "tar -xzvf $mun returns error:" $RETVAL >> tmp.$$ |
160 |
|
ls -l $INDIR"/"$file >> tmp.$$ |
161 |
|
ls -l $mun >> tmp.$$ |
162 |
|
mail -s 'parse_emails err_3' $ADDRERR < tmp.$$ |
163 |
|
rm -f tmp.$$ |
164 |
|
fi |
165 |
|
mv -f $INDIR"/"$file $INDIR"/../fail2process/"$file |
166 |
|
continue |
167 |
fi |
fi |
168 |
tdir=`cat $TEMPDIR"/out" | head -1 | sed -e 's|^./||g' | cut -d '/' -f 1` |
tdir=`cat $TEMPDIR"/out" | head -1 | sed -e 's|^./||g' | cut -d '/' -f 1` |
169 |
rm -f $TEMPDIR"/out" |
rm -f $TEMPDIR"/out" |
189 |
if test $PRT = 1 ; then echo " done" ; fi |
if test $PRT = 1 ; then echo " done" ; fi |
190 |
if test $PRT = 2 -a $nb_files != 0 ; then echo "" ; fi |
if test $PRT = 2 -a $nb_files != 0 ; then echo "" ; fi |
191 |
|
|
|
# echo -n "gzipping all the \"output.txt\" files ..." |
|
|
# ( |
|
|
# cd $OUTDIR |
|
|
# outp=`find . -name output.txt` |
|
|
# if test "x$outp" != x ; then |
|
|
# gzip $outp |
|
|
# fi |
|
|
# ) |
|
|
# echo " done" |
|
|
|
|
|
# echo -n "setting permissions to world-readable ..." |
|
|
# chmod -R a+rx $OUTDIR > /dev/null 2>&1 |
|
|
# echo " done" |
|
|
|
|
|
|
|