/[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.12 by jmc, Tue Feb 5 22:58:54 2008 UTC revision 1.17 by jmc, Wed Mar 19 00:55:28 2008 UTC
# Line 22  usage() Line 22  usage()
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 "  (-u |-unpack )EXE    use executable EXE to unpack e-mails"
26        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
# Line 32  usage() Line 34  usage()
34  INDIR="/u/u2/jmc/Mail/MITgcm-test"  INDIR="/u/u2/jmc/Mail/MITgcm-test"
35  OUTDIR="/u/u0/httpd/html/testing/results/"`date +%Y`"_"`date +%m`  OUTDIR="/u/u0/httpd/html/testing/results/"`date +%Y`"_"`date +%m`
36  TEMPDIR=./ptmp  TEMPDIR=./ptmp
37  MUNPACK=/u/edhill/local/bin/munpack  MUNPACK=munpack
38  ADDRERR=  ADDRERR=
39  PRT=1  PRT=1
40    
# Line 72  for ac_option ; do Line 74  for ac_option ; do
74              ac_prev=TEMPDIR ;;              ac_prev=TEMPDIR ;;
75          --tempd=* | -tempd=* | --t=* | -t=*)          --tempd=* | -tempd=* | --t=* | -t=*)
76              TEMPDIR=$ac_optarg ;;              TEMPDIR=$ac_optarg ;;
77          -a | --aa | -addr | --addr)  
78            -u | --u | -unpack | --unpack)
79                ac_prev=MUNPACK ;;
80            -u=* | --u=* | -unpack=* | --unpack=*)
81                MUNPACK=$ac_optarg ;;
82            
83            -a | --a | -addr | --addr)
84              ac_prev=ADDRERR ;;              ac_prev=ADDRERR ;;
85          -a=* | --aa=* | -addr=* | --addr=*)          -a=* | --a=* | -addr=* | --addr=*)
86              ADDRERR=$ac_optarg ;;              ADDRERR=$ac_optarg ;;
87            
88          *)          *)
89              # copy the file list to FL_#              # copy the file list to FL_#
90              echo "Error: don't understand argument \"$ac_option\""              echo "Error: don't understand argument \"$ac_option\""
# Line 87  for ac_option ; do Line 95  for ac_option ; do
95            
96  done  done
97    
98    if test ! -x $MUNPACK ; then
99            echo "ERROR: \"$MUNPACK\" is not executable"
100            exit 2
101    fi
102  if test ! -e $OUTDIR ; then  if test ! -e $OUTDIR ; then
103      mkdir $OUTDIR      mkdir $OUTDIR
104      RETVAL=$?      RETVAL=$?
105      if test "x$RETVAL" = x ; then      if test "x$RETVAL" != x0 ; then
106          echo "ERROR: directory \"$OUTDIR\" doesn't exist and can't be created"          echo "ERROR: directory \"$OUTDIR\" doesn't exist and can't be created"
107          exit 1          exit 3
108      fi      fi
109      chgrp gcmpack $OUTDIR      chgrp gcmpack $OUTDIR
110      chmod 775 $OUTDIR      chmod 775 $OUTDIR
# Line 106  if test $PRT = 1 ; then Line 118  if test $PRT = 1 ; then
118    echo "Using INDIR=\"$INDIR\""    echo "Using INDIR=\"$INDIR\""
119    echo -n "Unpacking the emails ..."    echo -n "Unpacking the emails ..."
120  elif test $nb_files != 0 ; then  elif test $nb_files != 0 ; then
121    echo "Unpacking $nb_files emails from '$INDIR' to '$OUTDIR'"    echo -n "Unpacking $nb_files emails ("`date`
122    if test "x$ADDRERR" != x ; then    if test "x$ADDRERR" != x ; then
123       echo " (send msg to '$ADDRERR' if Error)"       echo -n ", err-msg: '$ADDRERR'"
124    fi    fi
125    if test $PRT = 2 ; then echo -n " dir:" ; fi    echo ")"
126      echo " from '$INDIR' to '$OUTDIR'"
127  fi  fi
128    
129  for file in $all_files ; do  for file in $all_files ; do
# Line 118  for file in $all_files ; do Line 131  for file in $all_files ; do
131      #  create local copy      #  create local copy
132      test -e $TEMPDIR  &&  rm -rf $TEMPDIR      test -e $TEMPDIR  &&  rm -rf $TEMPDIR
133      mkdir $TEMPDIR      mkdir $TEMPDIR
134      cp $INDIR"/"$file $TEMPDIR      RETVAL=$?
135        if test "x$RETVAL" = x0 ; then
136          cp $INDIR"/"$file $TEMPDIR
137          RETVAL=$?
138        fi
139        if test "x$RETVAL" != x0 ; then
140          if test "x$ADDRERR" != x ; then
141            echo "parsing email error" > tmp.$$
142            echo " processing file: '$INDIR/$file'" >> tmp.$$
143            echo -n "'mkdir $TEMPDIR' or 'cp $INDIR/$file $TEMPDIR'" >> tmp.$$
144            echo " returns error $RETVAL" >> tmp.$$
145            mail -s 'parse_emails err_0' $ADDRERR < tmp.$$
146            rm -f tmp.$$
147          fi
148          mv -f $INDIR"/"$file $INDIR"/../fail2process/"$file
149          continue
150        fi
151    
152      #  ignore multi-part messages      #  ignore multi-part messages
153      grep "Content-Type: message/partial" $INDIR"/"$file > /dev/null 2>&1      grep "Content-Type: message/partial" $INDIR"/"$file > /dev/null 2>&1
# Line 177  for file in $all_files ; do Line 206  for file in $all_files ; do
206          done          done
207          sdir=$tdir"_"$ad          sdir=$tdir"_"$ad
208      fi      fi
209      if test $PRT = 2 ; then echo -n " '$sdir'" ; fi      if test $PRT = 2 ; then echo " '$sdir'" ; fi
210      mv $TEMPDIR"/"$tdir $OUTDIR"/"$sdir > /dev/null 2>&1      mv $TEMPDIR"/"$tdir $OUTDIR"/"$sdir > /dev/null 2>&1
211        RETVAL=$?
212        if test "x$RETVAL" != x0 ; then
213          if test "x$ADDRERR" != x ; then
214            echo "parsing email error" > tmp.$$
215            echo "mv $TEMPDIR/$tdir $OUTDIR/$sdir returns error:" $RETVAL >> tmp.$$
216            echo -n "in dir: $TEMPDIR : " ; ls -l $TEMPDIR  >> tmp.$$
217            echo -n "in dir: $OUTDIR : " ; ls -l $OUTDIR  >> tmp.$$
218            mail -s 'parse_emails err_4' $ADDRERR < tmp.$$
219            rm -f tmp.$$
220          fi
221          mv -f $INDIR"/"$file $INDIR"/../fail2process/"$file
222          continue
223        fi
224      chmod -R a+rx $OUTDIR"/"$sdir > /dev/null 2>&1      chmod -R a+rx $OUTDIR"/"$sdir > /dev/null 2>&1
225  #   gzip $OUTDIR"/"$sdir"/output.txt"  #   gzip $OUTDIR"/"$sdir"/output.txt"
226    
# Line 187  for file in $all_files ; do Line 229  for file in $all_files ; do
229    
230  done  done
231  if test $PRT = 1 ; then echo "  done" ; fi  if test $PRT = 1 ; then echo "  done" ; fi
 if test $PRT = 2 -a $nb_files != 0 ; then echo "" ; fi  
232    

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.17

  ViewVC Help
Powered by ViewVC 1.1.22