--- mitgcm.org/front_content/parse_emails 2008/02/26 21:34:00 1.14 +++ mitgcm.org/front_content/parse_emails 2008/03/04 17:21:40 1.16 @@ -1,6 +1,6 @@ #! /usr/bin/env bash -# $Header: /home/ubuntu/mnt/e9_copy/mitgcm.org/front_content/parse_emails,v 1.14 2008/02/26 21:34:00 jmc Exp $ +# $Header: /home/ubuntu/mnt/e9_copy/mitgcm.org/front_content/parse_emails,v 1.16 2008/03/04 17:21:40 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 @@ -102,7 +102,7 @@ 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 3 fi @@ -120,7 +120,7 @@ elif test $nb_files != 0 ; then echo "Unpacking $nb_files emails from '$INDIR' to '$OUTDIR'" if test "x$ADDRERR" != x ; then - echo " (send msg to '$ADDRERR' if Error)" + echo " "`date`" (send msg to '$ADDRERR' if Error)" fi if test $PRT = 2 ; then echo -n " dir:" ; fi fi @@ -130,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 @@ -191,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"