/[MITgcm]/mitgcm.org/front_content/get+parse_msg
ViewVC logotype

Annotation of /mitgcm.org/front_content/get+parse_msg

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.6 - (hide annotations) (download)
Sat Feb 3 15:52:10 2018 UTC (3 years, 8 months ago) by jmc
Branch: MAIN
Changes since 1.5: +44 -20 lines
- append process number to file-name (reduce risk of over-writing one)
- move message to "../postponed" when OUTDIR does not exist yet, and
  process them when a new OUTDIR is created.

1 jmc 1.1 #! /usr/bin/env bash
2    
3 jmc 1.6 # $Header: /u/gcmpack/mitgcm.org/front_content/get+parse_msg,v 1.5 2018/01/13 16:26:20 jmc Exp $
4 jmc 1.1 #
5     # The purpose of this script is to parse the emails produced by the
6     # MITgcm/verificaton/testreport script and store the data in a
7     # reasonable location.
8    
9     usage()
10     {
11     echo
12     echo "Usage: $0 [OPTIONS]"
13     echo
14     echo "where possible OPTIONS are:"
15     echo " (-h|-help) print usage"
16     echo " (-s|-silent) silent mode"
17     echo " (-v|-verbose) verbose mode"
18     echo " (-i |-ind )DIR get mpack-created emails from DIR"
19     echo " [def=\"$INDIR\"]"
20     echo " (-o |-outd )DIR write the data to DIR"
21     echo " [def=\"$BASEDIR/$monthDir\"]"
22     echo " (-t |-tempd )DIR use temporary directory DIR"
23     echo " [def=\"$TEMPDIR\"]"
24     echo " (-u |-unpack )EXE use executable EXE to unpack e-mails"
25     echo " [def=\"$MUNPACK\"]"
26     echo " (-a |-addr )ADDR send e-mail to ADDR if Error"
27     echo " [def='"$ADDRERR"']"
28     echo
29     exit 1
30     }
31    
32     # defaults
33     HERE=`pwd`
34 jmc 1.6 sufx=$$
35 jmc 1.1 #INDIR="/u/u2/jmc/Mail/MITgcm-test"
36     #BASEDIR="/u/u0/httpd/html/testing/results"
37     RHOST="jm_c@mitgcm-mm.mit.edu" ; M_DIR="Mail/MITgcm-test"
38     INDIR="/home/jm_c/testing/MITgcm-test"
39     BASEDIR="/net/zany.mit.edu/data/ORWELL/export-9/mitgcm-testing/results"
40     monthDir=`date +%Y`"_"`date +%m`
41     OUTDIR=
42     ADDRERR=
43     MUNPACK=$HERE/munpack
44     UnpTmpD="/var/tmp/m-prts-$USER"
45 jmc 1.6 TR_LIST="TTT.$sufx"
46 jmc 1.3 TEMPDIR="/tmp/prc_emails_$USER"
47 jmc 1.6 STDOUT="$TEMPDIR/outp.$sufx"
48     ERRMSG="/tmp/tmp.$sufx"
49 jmc 1.1 PRT=1
50    
51     #---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
52     # Parse options
53     ac_prev=
54     for ac_option ; do
55    
56     # If the previous option needs an argument, assign it.
57     if test -n "$ac_prev"; then
58     eval "$ac_prev=\$ac_option"
59     ac_prev=
60     continue
61     fi
62    
63     ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
64    
65     case $ac_option in
66    
67     -help | --help | -h | --h)
68     usage ;;
69     -s | --s | -silent | --silent)
70     PRT=0 ;;
71     -v | --v | -verbose | --verbose)
72     PRT=2 ;;
73    
74     -ind | --ind | -i | --i)
75     ac_prev=INDIR ;;
76     --ind=* | -ind=* | --i=* | -i=*)
77     INDIR=$ac_optarg ;;
78    
79     -outd | --outd | -o | --o)
80     ac_prev=OUTDIR ;;
81     --outd=* | -outd=* | --o=* | -o=*)
82     OUTDIR=$ac_optarg ;;
83    
84     -tempd | --tempd | -t | --t)
85     ac_prev=TEMPDIR ;;
86     --tempd=* | -tempd=* | --t=* | -t=*)
87     TEMPDIR=$ac_optarg ;;
88    
89     -u | --u | -unpack | --unpack)
90     ac_prev=MUNPACK ;;
91     -u=* | --u=* | -unpack=* | --unpack=*)
92     MUNPACK=$ac_optarg ;;
93    
94     -a | --a | -addr | --addr)
95     ac_prev=ADDRERR ;;
96     -a=* | --a=* | -addr=* | --addr=*)
97     ADDRERR=$ac_optarg ;;
98    
99     *)
100     date
101     echo "Error: don't understand argument \"$ac_option\""
102     usage
103     ;;
104    
105     esac
106    
107     done
108    
109     if test ! -x $MUNPACK ; then
110     date
111     echo "ERROR: \"$MUNPACK\" is not executable"
112     exit 2
113     fi
114 jmc 1.6
115     #-- set OUTDIR (if not yet set) and create it (if not already there)
116 jmc 1.1 if test "x$OUTDIR" = x ; then
117     OUTDIR="$BASEDIR/$monthDir"
118     else
119     monthDir=0
120     fi
121 jmc 1.6 oldMsg=0
122 jmc 1.1 if test ! -e $OUTDIR ; then
123     mkdir $OUTDIR
124     RETVAL=$?
125     if test "x$RETVAL" != x0 ; then
126     date
127     echo "ERROR: directory \"$OUTDIR\" doesn't exist and can't be created"
128     exit 3
129     else
130     echo "Successfully created new dir: \"$OUTDIR\""
131     fi
132     chgrp gcmpack $OUTDIR
133     chmod 775 $OUTDIR
134 jmc 1.6 #-- In case a new-outpdir is made, process old files from "postponed"
135     # (if any old msg there) by changing INDIR to ../postponed
136     oldMsg=`ls -1 ${INDIR}/../postponed | wc -l`
137     if test $oldMsg != 0 ; then
138     newInD=`dirname $INDIR`
139     INDIR="$newInD/postponed"
140     echo " Change INDIR to '$INDIR' ($oldMsg old messages)"
141     oldMsg=1
142     fi
143 jmc 1.1 fi
144    
145 jmc 1.6 #-- check that $TEMPDIR exist (needed for STDOUT)
146 jmc 1.4 if test ! -d $TEMPDIR ; then
147     mkdir $TEMPDIR
148     RETVAL=$?
149     if test "x$RETVAL" != x0 ; then
150     date
151     echo "ERROR: directory \"$TEMPDIR\" doesn't exist and can't be created"
152     exit 4
153     fi
154     fi
155    
156 jmc 1.6
157     #---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
158     if test $oldMsg = 0 ; then
159    
160 jmc 1.1 #- 1) check that $INDIR is empty
161 jmc 1.6 nbMsg=`ls -1 $INDIR | wc -l`
162     if test $nbMsg != 0 ; then
163 jmc 1.1 date
164     echo "ERROR: '$INDIR' is not empty ! --> exit"
165 jmc 1.4 exit 5
166 jmc 1.6 fi
167 jmc 1.1
168 jmc 1.6 nbMsg=0; ORIG=${RHOST}:$M_DIR
169     #- 2) scp all msg from ORIG to INDIR
170     cd $INDIR
171 jmc 1.1 scp -p ${RHOST}:$M_DIR/\* . > $STDOUT 2>&1
172     RETVAL=$?
173     if test "x$RETVAL" != x0 ; then
174     #echo " RETVAL='$RETVAL'"
175     RETVAL=`grep -v '^scp: No match\.$' $STDOUT | wc -l`
176     fi
177     if test "x$RETVAL" != x0 ; then
178     date
179     cat $STDOUT
180     echo "ERROR: when trying to scp msg from $ORIG to $INDIR"
181 jmc 1.4 #rm -f $STDOUT
182     exit 6
183 jmc 1.1 fi
184     nbMsg=`ls -1 | wc -l`
185     if test $nbMsg != 0 ; then
186     echo "> scp $nbMsg msg from '$ORIG' to '$INDIR'"
187     listMsg=`ls -1`
188 jmc 1.6 #- And rename msg by adding unique suffix
189     for xx in $listMsg ; do
190     mv $xx $xx.$sufx
191     done
192 jmc 1.1 fi
193 jmc 1.4 #rm -f $STDOUT
194 jmc 1.6 cd $HERE
195     #echo " nbMsg='$nbMsg' ; listMsg='$listMsg'"
196 jmc 1.1
197     #- 3) remove from ORIG all msg that we got here (this way it should be safe)
198 jmc 1.6 if test $nbMsg != 0 ; then
199 jmc 1.1 #echo "ssh $RHOST cd $M_DIR \; /bin/rm -f $listMsg"
200     ssh $RHOST cd $M_DIR \; /bin/rm -f $listMsg
201     RETVAL=$?
202     if test "x$RETVAL" != x0 ; then
203     echo "ERROR ( $RETVAL ) when trying to ssh+rm $nbMsg msg from $ORIG"
204 jmc 1.4 #- note: Checking for return-value from ssh command is not good enough,
205 jmc 1.1 # therefore we do not terminate if non-zero
206 jmc 1.4 # exit 7
207 jmc 1.1 fi
208 jmc 1.6 #- This is the log file that "check_outp" (run on baudelaire) was checking:
209 jmc 1.5 # logpfx="prc_emails_" ; sfx=`date +%m%d`
210     # logfile="/net/zany/data/ORWELL/export-7/u/jmc/testing/logs/${logpfx}$sfx"
211 jmc 1.6 #- update log-file to trigger a new "check_outp":
212 jmc 1.5 # if test -e $logfile ; then touch $logfile ; fi
213 jmc 1.6 fi
214     #echo 'Start processing msg locally'
215    
216 jmc 1.1 fi
217 jmc 1.6 #---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
218 jmc 1.1 #exit
219    
220     all_msg=`ls -1 $INDIR`
221     nb_msg=`echo "$all_msg" | grep -c '^msg\.'`
222     nb_tar=`echo "$all_msg" | grep -c '\.tar\.gz$'`
223     nb_files=`expr $nb_msg + $nb_tar`
224    
225     if test $PRT = 2 ; then
226     echo "Using OUTDIR=\"$OUTDIR\""
227     echo "Using INDIR=\"$INDIR\""
228     echo -n "Unpacking $nb_msg msg + $nb_tar tar-file ("`date`
229 jmc 1.6 echo -n ", sfx=$sufx"
230 jmc 1.1 if test "x$ADDRERR" != x ; then
231     echo -n ", err: $ADDRERR"
232     fi
233     echo ")"
234     elif test $nb_files != 0 ; then
235     echo -n "Unpacking $nb_msg msg + $nb_tar tar-file ("`date`
236 jmc 1.6 echo -n ", sfx=$sufx"
237 jmc 1.1 if test "x$ADDRERR" != x ; then
238     echo -n ", err: $ADDRERR"
239     fi
240     echo ")"
241     #echo " from '$INDIR' to '$OUTDIR'"
242     echo " to: '$OUTDIR'"
243     fi
244    
245     #---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
246    
247     #-- process list of message to detect group of multi-part msgs:
248     rm -f $TR_LIST
249     touch $TR_LIST
250    
251     flag=0
252     for xx in $all_msg
253     do
254     in=`grep -c $xx $TR_LIST`
255     if test $in = 0 ; then
256     it=`echo $xx | grep -c '\.tar\.gz$'`
257     if test $it = 1 ; then
258     echo $xx >> $TR_LIST
259     else
260     np=`grep -c 'Content-Type: message/partial' $INDIR/$xx`
261     if test $np = 0 ; then
262     echo $xx >> $TR_LIST
263     else
264     l=`sed -n '/Content-Type: message\/partial/=' $INDIR/$xx`
265     lp=`expr $l + 1`
266     id=`sed -n "$lp p" $INDIR/$xx`
267     partM=`( cd $INDIR ; grep -c "$id" msg.* | grep -v ':0$' | sed 's/:1$//' )`
268     echo $partM >> $TR_LIST
269     if test "x$ADDRERR" != x ; then flag=1
270     echo "multi-parts message:" $partM >> $ERRMSG
271     ( cd $INDIR ; ls -l $partM ) >> $ERRMSG
272     fi
273     fi
274     fi
275     fi
276     done
277     if test $flag = 1 ; then
278     mail -s 'parse_emails Multi-parts msg' $ADDRERR < $ERRMSG
279     rm -f $ERRMSG
280     fi
281     #cat $TR_LIST ; echo '----------------------------------'
282    
283     #---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
284    
285     #-- process list of individual + group of multi-part messages
286     Nbl=`wc -l $TR_LIST | cut -d ' ' -f 1`
287     n=0
288     while [ $n -lt $Nbl ] ; do
289     n=`expr $n + 1`
290     errFlg=0 ; prcM=''
291     grpM=`sed -n "$n p" $TR_LIST`
292     nm=`sed -n "$n p" $TR_LIST | wc -w | cut -d ' ' -f 1`
293    
294     #- create local copy
295     test -e $TEMPDIR && rm -rf $TEMPDIR
296     mkdir $TEMPDIR
297     RETVAL=$?
298     if test "x$RETVAL" = x0 ; then
299     ( cd $INDIR ; cp $grpM $TEMPDIR )
300     RETVAL=$?
301     fi
302     if test "x$RETVAL" != x0 ; then
303     if test "x$ADDRERR" != x ; then
304     echo "error parsing email '$grpM' :" > $ERRMSG
305     echo -n "'mkdir $TEMPDIR' or 'cp $INDIR/$grpM $TEMPDIR'" | tee -a $ERRMSG
306     echo " returns error $RETVAL" | tee -a $ERRMSG
307     mail -s 'parse_emails err_0' $ADDRERR < $ERRMSG
308     rm -f $ERRMSG
309     fi
310     ( cd $INDIR ; mv -f $grpM ../fail2process )
311     continue
312     fi
313    
314     #---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
315     it=`echo $grpM | grep -c '\.tar\.gz$'`
316     if test $it = 1 ; then
317     #- nothing to do: already a tar file!
318     trOutp=$grpM ; prcM=$grpM
319     else
320    
321     #-check that we have all the parts
322     if [ $PRT -ge 1 -a $nm -gt 1 ] ; then
323     echo " group (nm=$nm) of multi-parts msg: '$grpM'"
324     fi
325     for xx in $grpM ; do
326     np=`grep 'Content-Type: message/partial' $TEMPDIR/$xx \
327     | sed 's/^Content.*total=//' | sed 's/;$//'`
328     if test "x$np" = x -a $nm = 1 ; then np=1 ; fi
329     if test "x$np" != "x$nm" ; then
330     if test $errFlg = 0 ; then errFlg=1
331     echo "error parsing email '$grpM' :" > $ERRMSG
332     fi
333     echo " - Error: Number of parts='$np' in $xx but got '$nm' msg-files" \
334     | tee -a $ERRMSG
335     fi
336     done
337     if test $errFlg = 1 ; then
338     if test "x$ADDRERR" != x ; then
339     mail -s 'parse_emails err_1' $ADDRERR < $ERRMSG
340     fi
341     rm -f $ERRMSG
342     ( cd $INDIR ; mv -f $grpM ../fail2process )
343     continue
344     fi
345    
346     if test $nm = 1 ; then
347     #- unpack single part message:
348     xx=$grpM
349     prcM=$xx
350     if test $PRT = 2 ; then echo " unpack single-part msg: '$xx'" ; fi
351     ( cd $TEMPDIR ; $MUNPACK $xx > $STDOUT 2>&1 )
352     RETVAL=$?
353     if test "x$RETVAL" != x0 ; then errFlg=1
354     echo "error parsing email '$xx' :" > $ERRMSG
355     echo " - Error: $MUNPACK $xx returns: $RETVAL" | tee -a $ERRMSG
356     ls -l $INDIR"/"$xx >> $ERRMSG
357     else
358     trOutp=`tail -1 $STDOUT | cut -d ' ' -f 1`
359     if test ! -f $TEMPDIR/$trOutp ; then errFlg=1
360     echo "error parsing email '$xx' :" > $ERRMSG
361     echo " - Error: Missing output file '$trOutp' from $MUNPACK output:" \
362     | tee -a $ERRMSG
363     fi
364     fi
365     if test $errFlg = 1 ; then
366     cat $STDOUT | tee -a $ERRMSG
367     echo " <<<-----------------------"
368     if test "x$ADDRERR" != x ; then
369     mail -s 'parse_emails err_2s' $ADDRERR < $ERRMSG
370     fi
371     rm -f $ERRMSG
372     fi
373     rm -f $STDOUT
374    
375     else
376     #- unpack group of multi-parts message:
377    
378     #-unpack each part, in the right order:
379     j=0
380     while [ $j -lt $nm ] ; do
381     j=`expr $j + 1`
382     #- get the j^th part msg
383     xx=`( cd $TEMPDIR ; grep -c "Content-Type: message/partial; number=$j" $grpM \
384     | grep -v ':0$' | sed 's/:1$//' )`
385     if test $PRT = 2 ; then
386     echo -n " $j : xx='$xx' : "
387     grep 'Content-Type: message/partial' $TEMPDIR/$xx | sed 's/Content-Type: //'
388     fi
389     #- check
390     if test ! -f $TEMPDIR/$xx ; then
391     echo "error parsing email '$xx' :" > $ERRMSG
392     echo " - Error: Missing msg file '$xx' in $TEMPDIR:" | tee -a $ERRMSG
393     ls -l $TEMDIR | tee -a $ERRMSG
394     errFlg=1 ; echo " <<<-----------------------"
395     if test "x$ADDRERR" != x ; then
396     mail -s 'parse_emails err_2g' $ADDRERR < $ERRMSG
397     fi
398     rm -f $ERRMSG
399     else
400     if test $j = 1 ; then prcM=$xx ; else prcM="$prcM $xx" ; fi
401     #- do unpack
402     ( cd $TEMPDIR ; $MUNPACK $xx > $STDOUT 2>&1 )
403     RETVAL=$?
404     if test "x$RETVAL" != x0 ; then errFlg=1
405     echo "error parsing email '$xx' :" > $ERRMSG
406     echo " - Error: $MUNPACK $xx returns: $RETVAL" | tee -a $ERRMSG
407     ls -l $INDIR"/"$xx | tee -a $ERRMSG
408     cat $STDOUT | tee -a $ERRMSG
409     errFlg=1 ; echo " <<<-----------------------"
410     if test "x$ADDRERR" != x ; then
411     mail -s 'parse_emails err_2u' $ADDRERR < $ERRMSG
412     fi
413     rm -f $ERRMSG
414     fi
415     fi
416     if test $errFlg = 1 ; then j=`expr $nm + 1` ; fi
417    
418     if [ $j -lt $nm ] ; then
419     #- if not last part:
420     pfix=`cat $STDOUT | tail -1 | awk '{print $NF}'`
421     if test -d $UnpTmpD/$pfix ; then
422     lock=$UnpTmpD/$pfix/CT
423     if test -e $lock ; then
424     if test $PRT = 2 ; then echo " remove lock: $lock" ; fi
425     rm -f $lock
426     else
427     echo "error parsing email '$xx' :" > $ERRMSG
428     echo " - Error: lock file '$lock' not found from $MUNPACK output:" \
429     | tee -a $ERRMSG
430     cat $STDOUT | tee -a $ERRMSG
431     errFlg=1 ; echo " <<<-----------------------"
432     fi
433     else
434     echo "error parsing email '$xx' :" > $ERRMSG
435     echo " - Error: found no dir '$UnpTmpD/$pfix' from $MUNPACK output:" \
436     | tee -a $ERRMSG
437     cat $STDOUT | tee -a $ERRMSG
438     errFlg=1 ; echo " <<<-----------------------"
439     fi
440     elif [ $j -eq $nm ] ; then
441     #- if last part:
442     trOutp=`tail -1 $STDOUT | cut -d ' ' -f 1`
443     if test ! -f $TEMPDIR/$trOutp ; then
444     echo "error parsing email '$xx' :" > $ERRMSG
445     echo " - Error: Missing output file '$trOutp' from $MUNPACK output:" \
446     | tee -a $ERRMSG
447     cat $STDOUT | tee -a $ERRMSG
448     errFlg=1 ; echo " <<<-----------------------"
449     fi
450     fi
451     if [ $errFlg -eq 1 -a $j -le $nm ] ; then j=$nm
452     if test "x$ADDRERR" != x ; then
453     mail -s 'parse_emails err_2m' $ADDRERR < $ERRMSG
454     fi
455     rm -f $ERRMSG
456     fi
457     rm -f $STDOUT
458     done
459     fi
460     #-- in case of error: mv all $grpM msg to "fail2proc"
461     if test $errFlg = 1 ; then
462     ( cd $INDIR ; mv -f $grpM ../fail2process )
463     continue
464     fi
465     if test $PRT = 2 ; then
466     if test -f $TEMPDIR/$trOutp ; then ls -l $TEMPDIR/$trOutp ; fi
467     fi
468    
469     fi
470     #---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
471    
472     #-- un-tar
473     #( cd $TEMPDIR ; tar -xzvf $trOutp > $STDOUT )
474     # to remove small files "._mydir" that some MAC OS are adding
475     # (for each file or dir) to a tar-file, use option "--exclude=":
476     ( cd $TEMPDIR ; tar -xzvf $trOutp --exclude="._*" > $STDOUT 2> $ERRMSG )
477     RETVAL=$?
478     #echo "--- content of file $STDOUT (STDOUT):"
479     #cat $STDOUT
480     #echo "--- content of file $ERRMSG (ERRMSG):"
481     #cat $ERRMSG
482     if test "x$RETVAL" != x0 ; then
483     echo "parsing email error" >> $ERRMSG
484     echo " - Error: tar -xzvf $trOutp returns:" $RETVAL | tee -a $ERRMSG
485     ( cd $INDIR ; ls -l $prcM ) | tee -a $ERRMSG
486     ls -l $TEMPDIR/$trOutp | tee -a $ERRMSG
487     if test "x$ADDRERR" != x ; then
488     mail -s 'parse_emails err_3a' $ADDRERR < $ERRMSG
489     fi
490     rm -f $ERRMSG
491     ( cd $INDIR ; mv -f $grpM ../fail2process )
492     continue
493     fi
494     test -f $ERRMSG && rm -f $ERRMSG
495     #--
496     tdir=`cat $STDOUT | head -1 | sed -e 's|^./||g' | cut -d '/' -f 1`
497     if test -d $TEMPDIR/$tdir ; then
498     rm -f $STDOUT
499     else
500     echo "parsing email error" > $ERRMSG
501     echo " - Error: fail to get dir output name 'tdir=$tdir'" | tee -a $ERRMSG
502     echo " (cont) from tar file '$TEMPDIR/$trOutp'" | tee -a $ERRMSG
503     if test "x$ADDRERR" != x ; then
504     mail -s 'parse_emails err_3b' $ADDRERR < $ERRMSG
505     fi
506     rm -f $ERRMSG
507     ( cd $INDIR ; mv -f $grpM ../fail2process )
508     continue
509     fi
510    
511     #-- select which Monthly Output Dir:
512     locDir=$OUTDIR
513     if test "x$monthDir" != x0 ; then
514     dd=`echo $tdir | sed 's/_/ /g' | awk '{ for(i=1;i<=NF;i++) print $i }'\
515     | grep '[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]' | tail -1`
516     mn=`echo $dd | sed 's/..$//' | sed 's/..$/_&/'`
517     if test "x$mn" != "x$monthDir" ; then
518     if test "x$mn" = x ; then
519     if [ $PRT -ge 1 ] ; then echo " cannot get month from '$tdir'" ; fi
520     else
521     locDir="$BASEDIR/$mn"
522     if test ! -d $locDir ; then
523     if [ $PRT -ge 1 ] ; then
524     echo "NO DIR: '$locDir' => '$tdir' POSTPONED"
525     fi
526     if test "x$ADDRERR" != x ; then
527     echo "parsing email error" > $ERRMSG
528     echo " no dir '$locDir' for outp. '$tdir'" >> $ERRMSG
529     ( cd $INDIR ; ls -l $prcM ) >> $ERRMSG
530     mail -s 'parse_emails err_4' $ADDRERR < $ERRMSG
531     rm -f $ERRMSG
532     fi
533 jmc 1.6 ( cd $INDIR ; mv -f $grpM ../postponed )
534 jmc 1.1 continue
535     fi
536     fi
537     fi
538     fi
539    
540     #-- copy to $locDir and rename if necessary
541     sdir=$tdir
542     # if test -e $locDir"/"$tdir ; then
543     sdir=`echo $tdir | sed 's/_[0-9]*$//'`
544     ad=0
545     while test -e $locDir"/"$sdir"_"$ad ; do
546     ad=$(( $ad + 1 ))
547     done
548     sdir=$sdir"_"$ad
549     # fi
550     if [ $PRT -ge 1 ] ; then
551     if test "x$locDir" = "x$OUTDIR"
552     then echo " '$sdir' ($prcM)"
553     else echo " '$sdir' ($prcM) => '$locDir'"
554     fi
555     fi
556     mv $TEMPDIR"/"$tdir $locDir"/"$sdir > /dev/null 2>&1
557     RETVAL=$?
558     if test "x$RETVAL" != x0 ; then
559     if test "x$ADDRERR" != x ; then
560     echo "parsing email error" > $ERRMSG
561     echo " - Error: mv $TEMPDIR/$tdir $locDir/$sdir returns:" $RETVAL \
562     | tee -a $ERRMSG
563     echo -n " in dir: $TEMPDIR : " ; ls -l $TEMPDIR | tee -a $ERRMSG
564     echo -n " in dir: $OUTDIR : " ; ls -l $locDir | tee -a $ERRMSG
565     mail -s 'parse_emails err_5' $ADDRERR < $ERRMSG
566     rm -f $ERRMSG
567     fi
568     ( cd $INDIR ; mv -f $grpM ../fail2process )
569     continue
570     fi
571     chmod -R a+rx $locDir"/"$sdir > /dev/null 2>&1
572    
573     #-- remove the original message files
574     ( cd $INDIR ; rm -f $grpM )
575    
576     done
577     rm -f $TR_LIST
578     if test $PRT = 2 ; then echo " done" ; fi
579    

  ViewVC Help
Powered by ViewVC 1.1.22