| 6 |
# MITgcm/verificaton/testreport script and store the data in a |
# MITgcm/verificaton/testreport script and store the data in a |
| 7 |
# reasonable location. |
# reasonable location. |
| 8 |
|
|
|
|
|
| 9 |
usage() |
usage() |
| 10 |
{ |
{ |
| 11 |
echo |
echo |
| 31 |
|
|
| 32 |
# defaults |
# defaults |
| 33 |
HERE=`pwd` |
HERE=`pwd` |
| 34 |
|
sufx=$$ |
| 35 |
#INDIR="/u/u2/jmc/Mail/MITgcm-test" |
#INDIR="/u/u2/jmc/Mail/MITgcm-test" |
| 36 |
#BASEDIR="/u/u0/httpd/html/testing/results" |
#BASEDIR="/u/u0/httpd/html/testing/results" |
| 37 |
RHOST="jm_c@mitgcm-mm.mit.edu" ; M_DIR="Mail/MITgcm-test" |
RHOST="jm_c@mitgcm-mm.mit.edu" ; M_DIR="Mail/MITgcm-test" |
| 42 |
ADDRERR= |
ADDRERR= |
| 43 |
MUNPACK=$HERE/munpack |
MUNPACK=$HERE/munpack |
| 44 |
UnpTmpD="/var/tmp/m-prts-$USER" |
UnpTmpD="/var/tmp/m-prts-$USER" |
| 45 |
TR_LIST='TTT.'$$ |
TR_LIST="TTT.$sufx" |
| 46 |
TEMPDIR=/tmp/prc_emails |
TEMPDIR="/tmp/prc_emails_$USER" |
| 47 |
STDOUT=$TEMPDIR/'outp.'$$ |
STDOUT="$TEMPDIR/outp.$sufx" |
| 48 |
ERRMSG=/tmp/tmp.$$ |
ERRMSG="/tmp/tmp.$sufx" |
| 49 |
PRT=1 |
PRT=1 |
| 50 |
|
|
| 51 |
#---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
#---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
| 111 |
echo "ERROR: \"$MUNPACK\" is not executable" |
echo "ERROR: \"$MUNPACK\" is not executable" |
| 112 |
exit 2 |
exit 2 |
| 113 |
fi |
fi |
| 114 |
|
|
| 115 |
|
#-- set OUTDIR (if not yet set) and create it (if not already there) |
| 116 |
if test "x$OUTDIR" = x ; then |
if test "x$OUTDIR" = x ; then |
| 117 |
OUTDIR="$BASEDIR/$monthDir" |
OUTDIR="$BASEDIR/$monthDir" |
| 118 |
else |
else |
| 119 |
monthDir=0 |
monthDir=0 |
| 120 |
fi |
fi |
| 121 |
|
oldMsg=0 |
| 122 |
if test ! -e $OUTDIR ; then |
if test ! -e $OUTDIR ; then |
| 123 |
mkdir $OUTDIR |
mkdir $OUTDIR |
| 124 |
RETVAL=$? |
RETVAL=$? |
| 131 |
fi |
fi |
| 132 |
chgrp gcmpack $OUTDIR |
chgrp gcmpack $OUTDIR |
| 133 |
chmod 775 $OUTDIR |
chmod 775 $OUTDIR |
| 134 |
|
#-- In case a new-outpdir is made, process old files from "postponed" |
| 135 |
|
# (if any old msg there) by changing INDIR to ../postponed |
| 136 |
|
oldMsg=`ls -1 ${INDIR}/../postponed | wc -l` |
| 137 |
|
if test $oldMsg != 0 ; then |
| 138 |
|
newInD=`dirname $INDIR` |
| 139 |
|
INDIR="$newInD/postponed" |
| 140 |
|
echo " Change INDIR to '$INDIR' ($oldMsg old messages)" |
| 141 |
|
oldMsg=1 |
| 142 |
|
fi |
| 143 |
fi |
fi |
| 144 |
|
|
| 145 |
|
#-- check that $TEMPDIR exist (needed for STDOUT) |
| 146 |
|
if test ! -d $TEMPDIR ; then |
| 147 |
|
mkdir $TEMPDIR |
| 148 |
|
RETVAL=$? |
| 149 |
|
if test "x$RETVAL" != x0 ; then |
| 150 |
|
date |
| 151 |
|
echo "ERROR: directory \"$TEMPDIR\" doesn't exist and can't be created" |
| 152 |
|
exit 4 |
| 153 |
|
fi |
| 154 |
|
fi |
| 155 |
|
|
| 156 |
|
|
| 157 |
#---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
#---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
| 158 |
|
if test $oldMsg = 0 ; then |
| 159 |
|
|
| 160 |
#- 1) check that $INDIR is empty |
#- 1) check that $INDIR is empty |
| 161 |
nbMsg=`ls -1 $INDIR | wc -l` |
nbMsg=`ls -1 $INDIR | wc -l` |
| 162 |
if test $nbMsg != 0 ; then |
if test $nbMsg != 0 ; then |
| 163 |
date |
date |
| 164 |
echo "ERROR: '$INDIR' is not empty ! --> exit" |
echo "ERROR: '$INDIR' is not empty ! --> exit" |
| 165 |
exit 4 |
exit 5 |
| 166 |
fi |
fi |
| 167 |
|
|
| 168 |
nbMsg=0; ORIG=${RHOST}:$M_DIR |
nbMsg=0; ORIG=${RHOST}:$M_DIR |
| 169 |
#- 2) scp all msg from ORIG to INDIR |
#- 2) scp all msg from ORIG to INDIR |
| 170 |
cd $INDIR |
cd $INDIR |
| 171 |
scp -p ${RHOST}:$M_DIR/\* . > $STDOUT 2>&1 |
scp -p ${RHOST}:$M_DIR/\* . > $STDOUT 2>&1 |
| 172 |
RETVAL=$? |
RETVAL=$? |
| 173 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
| 178 |
date |
date |
| 179 |
cat $STDOUT |
cat $STDOUT |
| 180 |
echo "ERROR: when trying to scp msg from $ORIG to $INDIR" |
echo "ERROR: when trying to scp msg from $ORIG to $INDIR" |
| 181 |
rm -f $STDOUT |
#rm -f $STDOUT |
| 182 |
exit 5 |
exit 6 |
| 183 |
fi |
fi |
|
rm -f $STDOUT |
|
| 184 |
nbMsg=`ls -1 | wc -l` |
nbMsg=`ls -1 | wc -l` |
| 185 |
if test $nbMsg != 0 ; then |
if test $nbMsg != 0 ; then |
| 186 |
echo "> scp $nbMsg msg from '$ORIG' to '$INDIR'" |
echo "> scp $nbMsg msg from '$ORIG' to '$INDIR'" |
| 187 |
listMsg=`ls -1` |
listMsg=`ls -1` |
| 188 |
fi |
#- And rename msg by adding unique suffix |
| 189 |
cd $HERE |
for xx in $listMsg ; do |
| 190 |
#echo " nbMsg='$nbMsg' ; listMsg='$listMsg'" |
mv $xx $xx.$sufx |
| 191 |
|
done |
| 192 |
|
fi |
| 193 |
|
#rm -f $STDOUT |
| 194 |
|
cd $HERE |
| 195 |
|
#echo " nbMsg='$nbMsg' ; listMsg='$listMsg'" |
| 196 |
|
|
| 197 |
#- 3) remove from ORIG all msg that we got here (this way it should be safe) |
#- 3) remove from ORIG all msg that we got here (this way it should be safe) |
| 198 |
if test $nbMsg != 0 ; then |
if test $nbMsg != 0 ; then |
| 199 |
#echo "ssh $RHOST cd $M_DIR \; /bin/rm -f $listMsg" |
#echo "ssh $RHOST cd $M_DIR \; /bin/rm -f $listMsg" |
| 200 |
ssh $RHOST cd $M_DIR \; /bin/rm -f $listMsg |
ssh $RHOST cd $M_DIR \; /bin/rm -f $listMsg |
| 201 |
RETVAL=$? |
RETVAL=$? |
| 202 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
| 203 |
echo "ERROR ( $RETVAL ) when trying to ssh+rm $nbMsg msg from $ORIG" |
echo "ERROR ( $RETVAL ) when trying to ssh+rm $nbMsg msg from $ORIG" |
| 204 |
#- note: Checking for return-value fron ssh command is not good enough, |
#- note: Checking for return-value from ssh command is not good enough, |
| 205 |
# therefore we do not terminate if non-zero |
# therefore we do not terminate if non-zero |
| 206 |
#exit 6 |
# exit 7 |
| 207 |
fi |
fi |
| 208 |
fi |
#- This is the log file that "check_outp" (run on baudelaire) was checking: |
| 209 |
#echo 'Start processing msg locally' |
# logpfx="prc_emails_" ; sfx=`date +%m%d` |
| 210 |
#exit |
# logfile="/net/zany/data/ORWELL/export-7/u/jmc/testing/logs/${logpfx}$sfx" |
| 211 |
|
#- update log-file to trigger a new "check_outp": |
| 212 |
|
# if test -e $logfile ; then touch $logfile ; fi |
| 213 |
|
fi |
| 214 |
|
#echo 'Start processing msg locally' |
| 215 |
|
|
| 216 |
|
fi |
| 217 |
#---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
#---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
| 218 |
|
#exit |
| 219 |
|
|
| 220 |
all_msg=`ls -1 $INDIR` |
all_msg=`ls -1 $INDIR` |
| 221 |
nb_msg=`echo "$all_msg" | grep -c '^msg\.'` |
nb_msg=`echo "$all_msg" | grep -c '^msg\.'` |
| 226 |
echo "Using OUTDIR=\"$OUTDIR\"" |
echo "Using OUTDIR=\"$OUTDIR\"" |
| 227 |
echo "Using INDIR=\"$INDIR\"" |
echo "Using INDIR=\"$INDIR\"" |
| 228 |
echo -n "Unpacking $nb_msg msg + $nb_tar tar-file ("`date` |
echo -n "Unpacking $nb_msg msg + $nb_tar tar-file ("`date` |
| 229 |
|
echo -n ", sfx=$sufx" |
| 230 |
if test "x$ADDRERR" != x ; then |
if test "x$ADDRERR" != x ; then |
| 231 |
echo -n ", err: $ADDRERR" |
echo -n ", err: $ADDRERR" |
| 232 |
fi |
fi |
| 233 |
echo ")" |
echo ")" |
| 234 |
elif test $nb_files != 0 ; then |
elif test $nb_files != 0 ; then |
| 235 |
echo -n "Unpacking $nb_msg msg + $nb_tar tar-file ("`date` |
echo -n "Unpacking $nb_msg msg + $nb_tar tar-file ("`date` |
| 236 |
|
echo -n ", sfx=$sufx" |
| 237 |
if test "x$ADDRERR" != x ; then |
if test "x$ADDRERR" != x ; then |
| 238 |
echo -n ", err: $ADDRERR" |
echo -n ", err: $ADDRERR" |
| 239 |
fi |
fi |
| 530 |
mail -s 'parse_emails err_4' $ADDRERR < $ERRMSG |
mail -s 'parse_emails err_4' $ADDRERR < $ERRMSG |
| 531 |
rm -f $ERRMSG |
rm -f $ERRMSG |
| 532 |
fi |
fi |
| 533 |
|
( cd $INDIR ; mv -f $grpM ../postponed ) |
| 534 |
continue |
continue |
| 535 |
fi |
fi |
| 536 |
fi |
fi |