/[MITgcm]/mitgcm.org/front_content/parse_emails
ViewVC logotype

Diff of /mitgcm.org/front_content/parse_emails

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

revision 1.15 by jmc, Thu Feb 28 20:03:45 2008 UTC revision 1.26 by jmc, Fri Jan 11 20:49:13 2013 UTC
# Line 11  usage() Line 11  usage()
11  {  {
12      echo      echo
13      echo "Usage:  $0 [OPTIONS]"      echo "Usage:  $0 [OPTIONS]"
14      echo      echo
15      echo "where possible OPTIONS are:"      echo "where possible OPTIONS are:"
16      echo "  (-h|-help)           print usage"      echo "  (-h|-help)           print usage"
17      echo "  (-s|-silent)         silent mode"      echo "  (-s|-silent)         silent mode"
# Line 19  usage() Line 19  usage()
19      echo "  (-i |-ind )DIR       get mpack-created emails from DIR"      echo "  (-i |-ind )DIR       get mpack-created emails from DIR"
20      echo "                         [def=\"$INDIR\"]"      echo "                         [def=\"$INDIR\"]"
21      echo "  (-o |-outd )DIR      write the data to DIR"      echo "  (-o |-outd )DIR      write the data to DIR"
22      echo "                         [def=\"$OUTDIR\"]"      echo "                         [def=\"$BASEDIR/$monthDir\"]"
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 "  (-u |-unpack )EXE    use executable EXE to unpack e-mails"      echo "  (-u |-unpack )EXE    use executable EXE to unpack e-mails"
26      echo "                         [def=\"$MUNPACK\"]"      echo "                         [def=\"$MUNPACK\"]"
27      echo "  (-a |-addr )ADDR     send e-mail to ADDR if Error"      echo "  (-a |-addr )ADDR     send e-mail to ADDR if Error"
28      echo "                         [def='"$ADDRERR"']"      echo "                         [def='"$ADDRERR"']"
29      echo      echo
30      exit 1      exit 1
31  }  }
32    
33  # defaults  # defaults
34    HERE=`pwd`
35  INDIR="/u/u2/jmc/Mail/MITgcm-test"  INDIR="/u/u2/jmc/Mail/MITgcm-test"
36  OUTDIR="/u/u0/httpd/html/testing/results/"`date +%Y`"_"`date +%m`  BASEDIR="/u/u0/httpd/html/testing/results"
37  TEMPDIR=./ptmp  monthDir=`date +%Y`"_"`date +%m`
38  MUNPACK=munpack  OUTDIR=
39  ADDRERR=  ADDRERR=
40    MUNPACK=$HERE/munpack
41    UnpTmpD="/var/tmp/m-prts-$USER"
42    TR_LIST='TTT.'$$
43    TEMPDIR=/tmp/prc_emails
44    STDOUT=$TEMPDIR/'outp.'$$
45    ERRMSG=/tmp/tmp.$$
46  PRT=1  PRT=1
47    
48    #---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
49  #  Parse options  #  Parse options
50  ac_prev=  ac_prev=
51  for ac_option ; do  for ac_option ; do
# Line 50  for ac_option ; do Line 58  for ac_option ; do
58      fi      fi
59    
60      ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`      ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
61        
62      case $ac_option in      case $ac_option in
63            
64          -help | --help | -h | --h)          -help | --help | -h | --h)
65              usage ;;              usage ;;
66          -s | --s | -silent | --silent)          -s | --s | -silent | --silent)
67              PRT=0 ;;              PRT=0 ;;
68          -v | --v | -verbose | --verbose)          -v | --v | -verbose | --verbose)
69              PRT=2 ;;              PRT=2 ;;
70            
71          -ind | --ind | -i | --i)          -ind | --ind | -i | --i)
72              ac_prev=INDIR ;;              ac_prev=INDIR ;;
73          --ind=* | -ind=* | --i=* | -i=*)          --ind=* | -ind=* | --i=* | -i=*)
74              INDIR=$ac_optarg ;;              INDIR=$ac_optarg ;;
75            
76          -outd | --outd | -o | --o)          -outd | --outd | -o | --o)
77              ac_prev=OUTDIR ;;              ac_prev=OUTDIR ;;
78          --outd=* | -outd=* | --o=* | -o=*)          --outd=* | -outd=* | --o=* | -o=*)
79              OUTDIR=$ac_optarg ;;              OUTDIR=$ac_optarg ;;
80            
81          -tempd | --tempd | -t | --t)          -tempd | --tempd | -t | --t)
82              ac_prev=TEMPDIR ;;              ac_prev=TEMPDIR ;;
83          --tempd=* | -tempd=* | --t=* | -t=*)          --tempd=* | -tempd=* | --t=* | -t=*)
# Line 79  for ac_option ; do Line 87  for ac_option ; do
87              ac_prev=MUNPACK ;;              ac_prev=MUNPACK ;;
88          -u=* | --u=* | -unpack=* | --unpack=*)          -u=* | --u=* | -unpack=* | --unpack=*)
89              MUNPACK=$ac_optarg ;;              MUNPACK=$ac_optarg ;;
90            
91          -a | --a | -addr | --addr)          -a | --a | -addr | --addr)
92              ac_prev=ADDRERR ;;              ac_prev=ADDRERR ;;
93          -a=* | --a=* | -addr=* | --addr=*)          -a=* | --a=* | -addr=* | --addr=*)
94              ADDRERR=$ac_optarg ;;              ADDRERR=$ac_optarg ;;
95    
96          *)          *)
97              # copy the file list to FL_#              date
98              echo "Error: don't understand argument \"$ac_option\""              echo "Error: don't understand argument \"$ac_option\""
99              usage              usage
100              ;;              ;;
101            
102       esac       esac
103        
104  done  done
105    
106  if test ! -x $MUNPACK ; then  if test ! -x $MUNPACK ; then
107          echo "ERROR: \"$MUNPACK\" is not executable"          date
108          exit 2          echo "ERROR: \"$MUNPACK\" is not executable"
109            exit 2
110    fi
111    if test "x$OUTDIR" = x ; then
112      OUTDIR="$BASEDIR/$monthDir"
113    else
114      monthDir=0
115  fi  fi
116  if test ! -e $OUTDIR ; then  if test ! -e $OUTDIR ; then
117      mkdir $OUTDIR      mkdir $OUTDIR
118      RETVAL=$?      RETVAL=$?
119      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
120          echo "ERROR: directory \"$OUTDIR\" doesn't exist and can't be created"          date
121          exit 3          echo "ERROR: directory \"$OUTDIR\" doesn't exist and can't be created"
122            exit 3
123        else
124            echo "Successfully created new dir: \"$OUTDIR\""
125      fi      fi
126      chgrp gcmpack $OUTDIR      chgrp gcmpack $OUTDIR
127      chmod 775 $OUTDIR      chmod 775 $OUTDIR
128  fi  fi
129    
130  all_files=`ls -1 $INDIR`  #---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
 nb_files=`echo "$all_files" | grep -c '^msg\.'`  
131    
132  if test $PRT = 1 ; then  all_msg=`ls -1 $INDIR`
133    nb_files=`echo "$all_msg" | grep -c '^msg\.'`
134    
135    if test $PRT = 2 ; then
136    echo "Using OUTDIR=\"$OUTDIR\""    echo "Using OUTDIR=\"$OUTDIR\""
137    echo "Using INDIR=\"$INDIR\""    echo "Using INDIR=\"$INDIR\""
138    echo -n "Unpacking the emails ..."    echo -n "Unpacking $nb_files emails ("`date`
139      if test "x$ADDRERR" != x ; then
140         echo -n ", err-msg: '$ADDRERR'"
141      fi
142      echo ")"
143  elif test $nb_files != 0 ; then  elif test $nb_files != 0 ; then
144    echo "Unpacking $nb_files emails from '$INDIR' to '$OUTDIR'"    echo -n "Unpacking $nb_files emails ("`date`
145    if test "x$ADDRERR" != x ; then    if test "x$ADDRERR" != x ; then
146       echo " (send msg to '$ADDRERR' if Error)"       echo -n ", err-msg: '$ADDRERR'"
147    fi    fi
148    if test $PRT = 2 ; then echo -n " dir:" ; fi    echo ")"
149      echo " from '$INDIR' to '$OUTDIR'"
150  fi  fi
151    
152  for file in $all_files ; do  #---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
153    
154    #-- process list of message to detect group of multi-part msgs:
155    rm -f $TR_LIST
156    touch $TR_LIST
157    
158    flag=0
159    for xx in $all_msg
160    do
161      in=`grep -c $xx $TR_LIST`
162      if test $in = 0 ; then
163        np=`grep -c 'Content-Type: message/partial' $INDIR/$xx`
164        if test $np = 0 ; then
165          echo $xx >> $TR_LIST
166        else
167          l=`sed -n '/Content-Type: message\/partial/=' $INDIR/$xx`
168          lp=`expr $l + 1`
169          id=`sed -n "$lp p" $INDIR/$xx`
170          partM=`( cd $INDIR ; grep -c "$id" msg.* | grep -v ':0$' | sed 's/:1$//' )`
171          echo $partM >> $TR_LIST
172          if test "x$ADDRERR" != x ; then flag=1
173            echo "multi-parts message:" $partM >> $ERRMSG
174            ( cd $INDIR ; ls -l $partM ) >> $ERRMSG
175          fi
176        fi
177      fi
178    done
179    if test $flag = 1 ; then
180        mail -s 'parse_emails Multi-parts msg' $ADDRERR < $ERRMSG
181        rm -f $ERRMSG
182    fi
183    #cat $TR_LIST ; echo '----------------------------------'
184    
185    #---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
186    
187    #-- process list of individual + group of multi-part messages
188    Nbl=`wc -l $TR_LIST | cut -d ' ' -f 1`
189    n=0
190    while [ $n -lt $Nbl ] ; do
191        n=`expr $n + 1`
192        errFlg=0 ; prcM=''
193        grpM=`sed -n "$n p" $TR_LIST`
194        nm=`sed -n "$n p" $TR_LIST | wc -w | cut -d ' ' -f 1`
195    
196      #  create local copy  #-  create local copy
197      test -e $TEMPDIR  &&  rm -rf $TEMPDIR      test -e $TEMPDIR  &&  rm -rf $TEMPDIR
198      mkdir $TEMPDIR      mkdir $TEMPDIR
199      RETVAL=$?      RETVAL=$?
200      if test "x$RETVAL" = x0 ; then      if test "x$RETVAL" = x0 ; then
201        cp $INDIR"/"$file $TEMPDIR        ( cd $INDIR ; cp $grpM $TEMPDIR )
202        RETVAL=$?        RETVAL=$?
203      fi      fi
204      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
205        if test "x$ADDRERR" != x ; then        if test "x$ADDRERR" != x ; then
206          echo "parsing email error" > tmp.$$          echo "error parsing email '$grpM' :" > $ERRMSG
207          echo " processing file: '$INDIR/$file'" >> tmp.$$          echo -n "'mkdir $TEMPDIR' or 'cp $INDIR/$grpM $TEMPDIR'" | tee -a $ERRMSG
208          echo -n "'mkdir $TEMPDIR' or 'cp $INDIR/$file $TEMPDIR'" >> tmp.$$          echo " returns error $RETVAL" | tee -a $ERRMSG
209          echo " returns error $RETVAL" >> tmp.$$          mail -s 'parse_emails err_0' $ADDRERR < $ERRMSG
210          mail -s 'parse_emails err_0' $ADDRERR < tmp.$$          rm -f $ERRMSG
         rm -f tmp.$$  
211        fi        fi
212        mv -f $INDIR"/"$file $INDIR"/../fail2process/"$file        ( cd $INDIR ; mv -f $grpM ../fail2process )
213        continue        continue
214      fi      fi
215    
216      #  ignore multi-part messages      #-check that we have all the parts
217      grep "Content-Type: message/partial" $INDIR"/"$file > /dev/null 2>&1      if [ $PRT -ge 1 -a $nm -gt 1 ] ; then
218      RETVAL=$?        echo " group (nm=$nm) of multi-parts msg: '$grpM'"
219      if test "x$RETVAL" = x0 ; then      fi
220        for xx in $grpM ; do
221          np=`grep 'Content-Type: message/partial' $TEMPDIR/$xx \
222                   | sed 's/^Content.*total=//' | sed 's/;$//'`
223          if test "x$np" = x -a $nm = 1 ; then np=1 ; fi
224          if test "x$np" != "x$nm" ; then
225            if test $errFlg = 0 ; then errFlg=1
226              echo "error parsing email '$grpM' :" > $ERRMSG
227            fi
228            echo " - Error: Number of parts='$np' in $xx but got '$nm' msg-files" \
229                 | tee -a $ERRMSG
230          fi
231        done
232        if test $errFlg = 1 ; then
233        if test "x$ADDRERR" != x ; then        if test "x$ADDRERR" != x ; then
234          echo "parsing email error" > tmp.$$          mail -s 'parse_emails err_1' $ADDRERR < $ERRMSG
         echo 'grep "Content-Type: message/partial" returns error:' $RETVAL >> tmp.$$  
         ls -l $INDIR"/"$file >> tmp.$$  
         mail -s 'parse_emails err_1' $ADDRERR < tmp.$$  
         rm -f tmp.$$  
235        fi        fi
236        mv -f $INDIR"/"$file $INDIR"/../fail2process/"$file        rm -f $ERRMSG
237          ( cd $INDIR ; mv -f $grpM ../fail2process )
238        continue        continue
239      fi      fi
240    
241      #  munpack      if test $nm = 1 ; then
242      mun=`( cd $TEMPDIR ; $MUNPACK $file | cut -d ' ' -f 1 | head -1 )`  #-  unpack single part message:
243          xx=$grpM
244          prcM=$xx
245          if test $PRT = 2 ; then echo " unpack single-part msg: '$xx'" ; fi
246          ( cd $TEMPDIR ; $MUNPACK $xx > $STDOUT 2>&1 )
247          RETVAL=$?
248          if test "x$RETVAL" != x0 ; then errFlg=1
249              echo "error parsing email '$xx' :" > $ERRMSG
250              echo " - Error: $MUNPACK $xx returns: $RETVAL" | tee -a $ERRMSG
251              ls -l $INDIR"/"$xx >> $ERRMSG
252          else
253              trOutp=`tail -1 $STDOUT | cut -d ' ' -f 1`
254              if test ! -f $TEMPDIR/$trOutp ; then errFlg=1
255                echo "error parsing email '$xx' :" > $ERRMSG
256                echo " - Error: Missing output file '$trOutp' from $MUNPACK output:" \
257                     | tee -a $ERRMSG
258              fi
259          fi
260          if test $errFlg = 1 ; then
261              cat $STDOUT | tee -a $ERRMSG
262              echo " <<<-----------------------"
263              if test "x$ADDRERR" != x ; then
264                mail -s 'parse_emails err_2s' $ADDRERR < $ERRMSG
265              fi
266              rm -f $ERRMSG
267          fi
268          rm -f $STDOUT
269    
270        else
271    #-  unpack group of multi-parts message:
272    
273        #-unpack each part, in the right order:
274          j=0
275          while [ $j -lt $nm ] ; do
276            j=`expr $j + 1`
277            #- get the j^th part msg
278            xx=`( cd $TEMPDIR ; grep -c "Content-Type: message/partial; number=$j" $grpM \
279                | grep -v ':0$' | sed 's/:1$//' )`
280            if test $PRT = 2 ; then
281              echo -n " $j : xx='$xx' : "
282              grep 'Content-Type: message/partial' $TEMPDIR/$xx | sed 's/Content-Type: //'
283            fi
284            #- check
285            if test ! -f $TEMPDIR/$xx ; then
286                echo "error parsing email '$xx' :" > $ERRMSG
287                echo " - Error: Missing msg file '$xx' in $TEMPDIR:" | tee -a $ERRMSG
288                ls -l $TEMDIR | tee -a $ERRMSG
289                errFlg=1 ; echo " <<<-----------------------"
290                if test "x$ADDRERR" != x ; then
291                  mail -s 'parse_emails err_2g' $ADDRERR < $ERRMSG
292                fi
293                rm -f $ERRMSG
294            else
295              if test $j = 1 ; then prcM=$xx ; else prcM="$prcM $xx" ; fi
296            #- do unpack
297              ( cd $TEMPDIR ; $MUNPACK $xx > $STDOUT 2>&1 )
298              RETVAL=$?
299              if test "x$RETVAL" != x0 ; then errFlg=1
300                echo "error parsing email '$xx' :" > $ERRMSG
301                echo " - Error: $MUNPACK $xx returns: $RETVAL" | tee -a $ERRMSG
302                ls -l $INDIR"/"$xx | tee -a $ERRMSG
303                cat $STDOUT | tee -a $ERRMSG
304                errFlg=1 ; echo " <<<-----------------------"
305                if test "x$ADDRERR" != x ; then
306                  mail -s 'parse_emails err_2u' $ADDRERR < $ERRMSG
307                fi
308                rm -f $ERRMSG
309              fi
310            fi
311            if test $errFlg = 1 ; then j=`expr $nm + 1` ; fi
312    
313            if [ $j -lt $nm ] ; then
314            #- if not last part:
315              pfix=`cat $STDOUT | tail -1 | awk '{print $NF}'`
316              if test -d $UnpTmpD/$pfix ; then
317                lock=$UnpTmpD/$pfix/CT
318                if test -e $lock ; then
319                  if test $PRT = 2 ; then echo "    remove lock: $lock" ; fi
320                  rm -f $lock
321                else
322                  echo "error parsing email '$xx' :" > $ERRMSG
323                  echo " - Error: lock file '$lock' not found from $MUNPACK output:" \
324                       | tee -a $ERRMSG
325                  cat $STDOUT | tee -a $ERRMSG
326                  errFlg=1 ; echo " <<<-----------------------"
327                fi
328              else
329                  echo "error parsing email '$xx' :" > $ERRMSG
330                  echo " - Error: found no dir '$UnpTmpD/$pfix' from $MUNPACK output:" \
331                       | tee -a $ERRMSG
332                  cat $STDOUT | tee -a $ERRMSG
333                  errFlg=1 ; echo " <<<-----------------------"
334              fi
335            elif [ $j -eq $nm ] ; then
336            #- if last part:
337               trOutp=`tail -1 $STDOUT | cut -d ' ' -f 1`
338               if test ! -f $TEMPDIR/$trOutp ; then
339                  echo "error parsing email '$xx' :" > $ERRMSG
340                  echo " - Error: Missing output file '$trOutp' from $MUNPACK output:" \
341                       | tee -a $ERRMSG
342                  cat $STDOUT | tee -a $ERRMSG
343                  errFlg=1 ; echo " <<<-----------------------"
344               fi
345            fi
346            if [ $errFlg -eq 1 -a $j -le $nm ] ; then j=$nm
347               if test "x$ADDRERR" != x ; then
348                  mail -s 'parse_emails err_2m' $ADDRERR < $ERRMSG
349               fi
350               rm -f $ERRMSG
351            fi
352            rm -f $STDOUT
353          done
354        fi
355        #--  in case of error: mv all $grpM msg to "fail2proc"
356        if test $errFlg = 1 ; then
357            ( cd $INDIR ; mv -f $grpM ../fail2process )
358            continue
359        fi
360        if test $PRT = 2 ; then
361              if test -f $TEMPDIR/$trOutp ; then ls -l $TEMPDIR/$trOutp ; fi
362        fi
363    
364    #---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
365    
366        #-- un-tar
367        #( cd $TEMPDIR ; tar -xzvf $trOutp > $STDOUT )
368        #   to remove small files "._mydir" that some MAC OS are adding
369        #   (for each file or dir) to a tar-file, use option "--exclude=":
370        ( cd $TEMPDIR ; tar -xzvf $trOutp --exclude="._*" > $STDOUT )
371      RETVAL=$?      RETVAL=$?
372      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
373          echo "parsing email error" > $ERRMSG
374          echo " - Error:  tar -xzvf $trOutp returns:" $RETVAL | tee -a $ERRMSG
375          ( cd $INDIR ; ls -l $prcM ) | tee -a $ERRMSG
376          ls -l $TEMPDIR/$trOutp  | tee -a $ERRMSG
377        if test "x$ADDRERR" != x ; then        if test "x$ADDRERR" != x ; then
378          echo "parsing email error" > tmp.$$          mail -s 'parse_emails err_3a' $ADDRERR < $ERRMSG
         echo "$MUNPACK $file returns error: $RETVAL" >> tmp.$$  
         ls -l $INDIR"/"$file >> tmp.$$  
         mail -s 'parse_emails err_2' $ADDRERR < tmp.$$  
         rm -f tmp.$$  
379        fi        fi
380        mv -f $INDIR"/"$file $INDIR"/../fail2process/"$file        rm -f $ERRMSG
381          ( cd $INDIR ; mv -f $grpM ../fail2process )
382        continue        continue
383      fi      fi
384        tdir=`cat $STDOUT | head -1 | sed -e 's|^./||g' | cut -d '/' -f 1`
385      #  un-tar      if test -d $TEMPDIR/$tdir ; then
386      ( cd $TEMPDIR ; tar -xzvf $mun > out )        rm -f $STDOUT
387      RETVAL=$?      else
388      if test "x$RETVAL" != x0 ; then        echo "parsing email error" > $ERRMSG
389          echo " - Error: fail to get dir output name 'tdir=$tdir'" | tee -a $ERRMSG
390          echo "   (cont) from tar file '$TEMPDIR/$trOutp'" | tee -a $ERRMSG
391        if test "x$ADDRERR" != x ; then        if test "x$ADDRERR" != x ; then
392          echo "parsing email error" > tmp.$$          mail -s 'parse_emails err_3b' $ADDRERR < $ERRMSG
         echo "tar -xzvf $mun returns error:" $RETVAL >> tmp.$$  
         ls -l $INDIR"/"$file >> tmp.$$  
         ls -l $mun >> tmp.$$  
         mail -s 'parse_emails err_3' $ADDRERR < tmp.$$  
         rm -f tmp.$$  
393        fi        fi
394        mv -f $INDIR"/"$file $INDIR"/../fail2process/"$file        rm -f $ERRMSG
395          ( cd $INDIR ; mv -f $grpM ../fail2process )
396        continue        continue
397      fi      fi
     tdir=`cat $TEMPDIR"/out" | head -1 | sed -e 's|^./||g' | cut -d '/' -f 1`  
     rm -f $TEMPDIR"/out"  
398    
399      #  copy to $OUTDIR and rename if necessary      #-- select which Monthly Output Dir:
400        locDir=$OUTDIR
401        if test "x$monthDir" != x0 ; then
402          dd=`echo $tdir | sed 's/_/ /g' | awk '{ for(i=1;i<=NF;i++) print $i }'\
403                   | grep '[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]' | tail -1`
404          mn=`echo $dd | sed 's/..$//' | sed 's/..$/_&/'`
405          if test "x$mn" != "x$monthDir" ; then
406            if test "x$mn" = x ; then
407              if [ $PRT -ge 1 ] ; then echo " cannot get month from '$tdir'" ; fi
408            else
409              locDir="$BASEDIR/$mn"
410              if test ! -d $locDir ; then
411                if [ $PRT -ge 1 ] ; then
412                  echo "NO DIR: '$locDir' => '$tdir' POSTPONED"
413                fi
414                if test "x$ADDRERR" != x ; then
415                  echo "parsing email error" > $ERRMSG
416                  echo "  no dir '$locDir' for outp. '$tdir'" >> $ERRMSG
417                  ( cd $INDIR ; ls -l $prcM ) >> $ERRMSG
418                  mail -s 'parse_emails err_4' $ADDRERR < $ERRMSG
419                  rm -f $ERRMSG
420                fi
421                continue
422              fi
423            fi
424          fi
425        fi
426    
427        #-- copy to $locDir and rename if necessary
428      sdir=$tdir      sdir=$tdir
429      if test -e $OUTDIR"/"$tdir ; then  #   if test -e $locDir"/"$tdir ; then
430          ad=0          sdir=`echo $tdir | sed 's/_[0-9]*$//'`
431          while test -e $OUTDIR"/"$tdir"_"$ad ; do          ad=0
432              ad=$(( $ad + 1 ))          while test -e $locDir"/"$sdir"_"$ad ; do
433          done              ad=$(( $ad + 1 ))
434          sdir=$tdir"_"$ad          done
435            sdir=$sdir"_"$ad
436    #   fi
437        if [ $PRT -ge 1 ] ; then
438          if test "x$locDir" = "x$OUTDIR"
439          then echo " '$sdir' ($prcM)"
440          else echo " '$sdir' ($prcM) => '$locDir'"
441          fi
442      fi      fi
443      if test $PRT = 2 ; then echo -n " '$sdir'" ; fi      mv $TEMPDIR"/"$tdir $locDir"/"$sdir > /dev/null 2>&1
     mv $TEMPDIR"/"$tdir $OUTDIR"/"$sdir > /dev/null 2>&1  
444      RETVAL=$?      RETVAL=$?
445      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
446        if test "x$ADDRERR" != x ; then        if test "x$ADDRERR" != x ; then
447          echo "parsing email error" > tmp.$$          echo "parsing email error" > $ERRMSG
448          echo "mv $TEMPDIR/$tdir $OUTDIR/$sdir returns error:" $RETVAL >> tmp.$$          echo " - Error: mv $TEMPDIR/$tdir $locDir/$sdir returns:" $RETVAL \
449          echo -n "in dir: $TEMPDIR : " ; ls -l $TEMPDIR  >> tmp.$$               | tee -a $ERRMSG
450          echo -n "in dir: $OUTDIR : " ; ls -l $OUTDIR  >> tmp.$$          echo -n "   in dir: $TEMPDIR : " ; ls -l $TEMPDIR  | tee -a $ERRMSG
451          mail -s 'parse_emails err_4' $ADDRERR < tmp.$$          echo -n "   in dir: $OUTDIR : " ; ls -l $locDir | tee -a $ERRMSG
452          rm -f tmp.$$          mail -s 'parse_emails err_5' $ADDRERR < $ERRMSG
453            rm -f $ERRMSG
454        fi        fi
455        mv -f $INDIR"/"$file $INDIR"/../fail2process/"$file        ( cd $INDIR ; mv -f $grpM ../fail2process )
456        continue        continue
457      fi      fi
458      chmod -R a+rx $OUTDIR"/"$sdir > /dev/null 2>&1      chmod -R a+rx $locDir"/"$sdir > /dev/null 2>&1
 #   gzip $OUTDIR"/"$sdir"/output.txt"  
459    
460      #  remove the original file      #-- remove the original message files
461      rm -f $INDIR"/"$file      ( cd $INDIR ; rm -f $grpM )
462    
463  done  done
464  if test $PRT = 1 ; then echo "  done" ; fi  rm -f $TR_LIST
465  if test $PRT = 2 -a $nb_files != 0 ; then echo "" ; fi  if test $PRT = 2 ; then echo "  done" ; fi
466    

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.26

  ViewVC Help
Powered by ViewVC 1.1.22