/[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.18 by jmc, Thu Sep 18 20:13:36 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                date
91              echo "Error: don't understand argument \"$ac_option\""              echo "Error: don't understand argument \"$ac_option\""
92              usage              usage
93              ;;              ;;
# Line 87  for ac_option ; do Line 96  for ac_option ; do
96            
97  done  done
98    
99    if test ! -x $MUNPACK ; then
100            date
101            echo "ERROR: \"$MUNPACK\" is not executable"
102            exit 2
103    fi
104  if test ! -e $OUTDIR ; then  if test ! -e $OUTDIR ; then
105      mkdir $OUTDIR      mkdir $OUTDIR
106      RETVAL=$?      RETVAL=$?
107      if test "x$RETVAL" = x ; then      if test "x$RETVAL" != x0 ; then
108            date
109          echo "ERROR: directory \"$OUTDIR\" doesn't exist and can't be created"          echo "ERROR: directory \"$OUTDIR\" doesn't exist and can't be created"
110          exit 1          exit 3
111      fi      fi
112      chgrp gcmpack $OUTDIR      chgrp gcmpack $OUTDIR
113      chmod 775 $OUTDIR      chmod 775 $OUTDIR
# Line 106  if test $PRT = 1 ; then Line 121  if test $PRT = 1 ; then
121    echo "Using INDIR=\"$INDIR\""    echo "Using INDIR=\"$INDIR\""
122    echo -n "Unpacking the emails ..."    echo -n "Unpacking the emails ..."
123  elif test $nb_files != 0 ; then  elif test $nb_files != 0 ; then
124    echo "Unpacking $nb_files emails from '$INDIR' to '$OUTDIR'"    echo -n "Unpacking $nb_files emails ("`date`
125    if test "x$ADDRERR" != x ; then    if test "x$ADDRERR" != x ; then
126       echo " (send msg to '$ADDRERR' if Error)"       echo -n ", err-msg: '$ADDRERR'"
127    fi    fi
128    if test $PRT = 2 ; then echo -n " dir:" ; fi    echo ")"
129      echo " from '$INDIR' to '$OUTDIR'"
130  fi  fi
131    
132  for file in $all_files ; do  for file in $all_files ; do
# Line 118  for file in $all_files ; do Line 134  for file in $all_files ; do
134      #  create local copy      #  create local copy
135      test -e $TEMPDIR  &&  rm -rf $TEMPDIR      test -e $TEMPDIR  &&  rm -rf $TEMPDIR
136      mkdir $TEMPDIR      mkdir $TEMPDIR
137      cp $INDIR"/"$file $TEMPDIR      RETVAL=$?
138        if test "x$RETVAL" = x0 ; then
139          cp $INDIR"/"$file $TEMPDIR
140          RETVAL=$?
141        fi
142        if test "x$RETVAL" != x0 ; then
143          if test "x$ADDRERR" != x ; then
144            echo "parsing email error" > tmp.$$
145            echo " processing file: '$INDIR/$file'" >> tmp.$$
146            echo -n "'mkdir $TEMPDIR' or 'cp $INDIR/$file $TEMPDIR'" >> tmp.$$
147            echo " returns error $RETVAL" >> tmp.$$
148            mail -s 'parse_emails err_0' $ADDRERR < tmp.$$
149            rm -f tmp.$$
150          fi
151          mv -f $INDIR"/"$file $INDIR"/../fail2process/"$file
152          continue
153        fi
154    
155      #  ignore multi-part messages      #  ignore multi-part messages
156      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 209  for file in $all_files ; do
209          done          done
210          sdir=$tdir"_"$ad          sdir=$tdir"_"$ad
211      fi      fi
212      if test $PRT = 2 ; then echo -n " '$sdir'" ; fi      if test $PRT = 2 ; then echo " '$sdir'" ; fi
213      mv $TEMPDIR"/"$tdir $OUTDIR"/"$sdir > /dev/null 2>&1      mv $TEMPDIR"/"$tdir $OUTDIR"/"$sdir > /dev/null 2>&1
214        RETVAL=$?
215        if test "x$RETVAL" != x0 ; then
216          if test "x$ADDRERR" != x ; then
217            echo "parsing email error" > tmp.$$
218            echo "mv $TEMPDIR/$tdir $OUTDIR/$sdir returns error:" $RETVAL >> tmp.$$
219            echo -n "in dir: $TEMPDIR : " ; ls -l $TEMPDIR  >> tmp.$$
220            echo -n "in dir: $OUTDIR : " ; ls -l $OUTDIR  >> tmp.$$
221            mail -s 'parse_emails err_4' $ADDRERR < tmp.$$
222            rm -f tmp.$$
223          fi
224          mv -f $INDIR"/"$file $INDIR"/../fail2process/"$file
225          continue
226        fi
227      chmod -R a+rx $OUTDIR"/"$sdir > /dev/null 2>&1      chmod -R a+rx $OUTDIR"/"$sdir > /dev/null 2>&1
228  #   gzip $OUTDIR"/"$sdir"/output.txt"  #   gzip $OUTDIR"/"$sdir"/output.txt"
229    
# Line 187  for file in $all_files ; do Line 232  for file in $all_files ; do
232    
233  done  done
234  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  
235    

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

  ViewVC Help
Powered by ViewVC 1.1.22