--- mitgcm.org/front_content/parse_emails 2008/02/17 03:20:24 1.13 +++ mitgcm.org/front_content/parse_emails 2008/02/28 20:03:45 1.15 @@ -1,6 +1,6 @@ #! /usr/bin/env bash -# $Header: /home/ubuntu/mnt/e9_copy/mitgcm.org/front_content/parse_emails,v 1.13 2008/02/17 03:20:24 jmc Exp $ +# $Header: /home/ubuntu/mnt/e9_copy/mitgcm.org/front_content/parse_emails,v 1.15 2008/02/28 20:03:45 jmc Exp $ # # The purpose of this script is to parse the emails produced by the # MITgcm/verificaton/testreport script and store the data in a @@ -22,6 +22,8 @@ echo " [def=\"$OUTDIR\"]" echo " (-t |-tempd )DIR use temporary directory DIR" echo " [def=\"$TEMPDIR\"]" + echo " (-u |-unpack )EXE use executable EXE to unpack e-mails" + echo " [def=\"$MUNPACK\"]" echo " (-a |-addr )ADDR send e-mail to ADDR if Error" echo " [def='"$ADDRERR"']" echo @@ -32,7 +34,7 @@ INDIR="/u/u2/jmc/Mail/MITgcm-test" OUTDIR="/u/u0/httpd/html/testing/results/"`date +%Y`"_"`date +%m` TEMPDIR=./ptmp -MUNPACK=/u/u2/jmc/testing/tools_mpack/munpack +MUNPACK=munpack ADDRERR= PRT=1 @@ -72,11 +74,17 @@ ac_prev=TEMPDIR ;; --tempd=* | -tempd=* | --t=* | -t=*) TEMPDIR=$ac_optarg ;; - -a | --aa | -addr | --addr) + + -u | --u | -unpack | --unpack) + ac_prev=MUNPACK ;; + -u=* | --u=* | -unpack=* | --unpack=*) + MUNPACK=$ac_optarg ;; + + -a | --a | -addr | --addr) ac_prev=ADDRERR ;; - -a=* | --aa=* | -addr=* | --addr=*) + -a=* | --a=* | -addr=* | --addr=*) ADDRERR=$ac_optarg ;; - + *) # copy the file list to FL_# echo "Error: don't understand argument \"$ac_option\"" @@ -87,12 +95,16 @@ done +if test ! -x $MUNPACK ; then + echo "ERROR: \"$MUNPACK\" is not executable" + exit 2 +fi if test ! -e $OUTDIR ; then mkdir $OUTDIR RETVAL=$? - if test "x$RETVAL" = x ; then + if test "x$RETVAL" != x0 ; then echo "ERROR: directory \"$OUTDIR\" doesn't exist and can't be created" - exit 1 + exit 3 fi chgrp gcmpack $OUTDIR chmod 775 $OUTDIR @@ -118,7 +130,23 @@ # create local copy test -e $TEMPDIR && rm -rf $TEMPDIR mkdir $TEMPDIR - cp $INDIR"/"$file $TEMPDIR + RETVAL=$? + if test "x$RETVAL" = x0 ; then + cp $INDIR"/"$file $TEMPDIR + RETVAL=$? + fi + if test "x$RETVAL" != x0 ; then + if test "x$ADDRERR" != x ; then + echo "parsing email error" > tmp.$$ + echo " processing file: '$INDIR/$file'" >> tmp.$$ + echo -n "'mkdir $TEMPDIR' or 'cp $INDIR/$file $TEMPDIR'" >> tmp.$$ + echo " returns error $RETVAL" >> tmp.$$ + mail -s 'parse_emails err_0' $ADDRERR < tmp.$$ + rm -f tmp.$$ + fi + mv -f $INDIR"/"$file $INDIR"/../fail2process/"$file + continue + fi # ignore multi-part messages grep "Content-Type: message/partial" $INDIR"/"$file > /dev/null 2>&1 @@ -179,6 +207,19 @@ fi if test $PRT = 2 ; then echo -n " '$sdir'" ; fi mv $TEMPDIR"/"$tdir $OUTDIR"/"$sdir > /dev/null 2>&1 + RETVAL=$? + if test "x$RETVAL" != x0 ; then + if test "x$ADDRERR" != x ; then + echo "parsing email error" > tmp.$$ + echo "mv $TEMPDIR/$tdir $OUTDIR/$sdir returns error:" $RETVAL >> tmp.$$ + echo -n "in dir: $TEMPDIR : " ; ls -l $TEMPDIR >> tmp.$$ + echo -n "in dir: $OUTDIR : " ; ls -l $OUTDIR >> tmp.$$ + mail -s 'parse_emails err_4' $ADDRERR < tmp.$$ + rm -f tmp.$$ + fi + mv -f $INDIR"/"$file $INDIR"/../fail2process/"$file + continue + fi chmod -R a+rx $OUTDIR"/"$sdir > /dev/null 2>&1 # gzip $OUTDIR"/"$sdir"/output.txt"