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_$USER" |
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 |
#---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
#-- check that $TEMPDIR exist (needed for STDOUT) |
|
#- 0) check that $TEMPDIR exist (needed for STDOUT) |
|
146 |
if test ! -d $TEMPDIR ; then |
if test ! -d $TEMPDIR ; then |
147 |
mkdir $TEMPDIR |
mkdir $TEMPDIR |
148 |
RETVAL=$? |
RETVAL=$? |
153 |
fi |
fi |
154 |
fi |
fi |
155 |
|
|
156 |
|
|
157 |
|
#---+----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 5 |
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 |
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 |
|
#- And rename msg by adding unique suffix |
189 |
|
for xx in $listMsg ; do |
190 |
|
mv $xx $xx.$sufx |
191 |
|
done |
192 |
fi |
fi |
193 |
#rm -f $STDOUT |
#rm -f $STDOUT |
194 |
cd $HERE |
cd $HERE |
195 |
#echo " nbMsg='$nbMsg' ; listMsg='$listMsg'" |
#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=$? |
205 |
# therefore we do not terminate if non-zero |
# therefore we do not terminate if non-zero |
206 |
# exit 7 |
# exit 7 |
207 |
fi |
fi |
208 |
#- This is the log file that "check_outp" (run on baudelaire) was checking: |
#- This is the log file that "check_outp" (run on baudelaire) was checking: |
209 |
# logpfx="prc_emails_" ; sfx=`date +%m%d` |
# logpfx="prc_emails_" ; sfx=`date +%m%d` |
210 |
# logfile="/net/zany/data/ORWELL/export-7/u/jmc/testing/logs/${logpfx}$sfx" |
# logfile="/net/zany/data/ORWELL/export-7/u/jmc/testing/logs/${logpfx}$sfx" |
211 |
#- update log-file to trigger a new "check_outp": |
#- update log-file to trigger a new "check_outp": |
212 |
# if test -e $logfile ; then touch $logfile ; fi |
# if test -e $logfile ; then touch $logfile ; fi |
213 |
fi |
fi |
214 |
#echo 'Start processing msg locally' |
#echo 'Start processing msg locally' |
|
#exit |
|
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 |