--- mitgcm.org/front_content/parse_emails 2008/02/26 21:34:00 1.14 +++ mitgcm.org/front_content/parse_emails 2008/03/19 00:55:28 1.17 @@ -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.17 2008/03/19 00:55:28 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 @@ -118,11 +118,12 @@ echo "Using INDIR=\"$INDIR\"" echo -n "Unpacking the emails ..." elif test $nb_files != 0 ; then - echo "Unpacking $nb_files emails from '$INDIR' to '$OUTDIR'" + echo -n "Unpacking $nb_files emails ("`date` if test "x$ADDRERR" != x ; then - echo " (send msg to '$ADDRERR' if Error)" + echo -n ", err-msg: '$ADDRERR'" fi - if test $PRT = 2 ; then echo -n " dir:" ; fi + echo ")" + echo " from '$INDIR' to '$OUTDIR'" fi for file in $all_files ; do @@ -130,7 +131,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 @@ -189,8 +206,21 @@ done sdir=$tdir"_"$ad fi - if test $PRT = 2 ; then echo -n " '$sdir'" ; fi + if test $PRT = 2 ; then echo " '$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" @@ -199,5 +229,4 @@ done if test $PRT = 1 ; then echo " done" ; fi -if test $PRT = 2 -a $nb_files != 0 ; then echo "" ; fi