/[MITgcm]/mitgcm.org/front_content/get+parse_msg
ViewVC logotype

Diff of /mitgcm.org/front_content/get+parse_msg

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.2 by jmc, Sat Jan 6 20:51:40 2018 UTC revision 1.7 by jmc, Thu Mar 15 20:38:28 2018 UTC
# Line 31  usage() Line 31  usage()
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"
# Line 41  OUTDIR= Line 42  OUTDIR=
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-|--+----|
# Line 110  if test ! -x $MUNPACK ; then Line 111  if test ! -x $MUNPACK ; then
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=$?
# Line 127  if test ! -e $OUTDIR ; then Line 131  if test ! -e $OUTDIR ; then
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        if test $monthDir != 0 ; then
137          oldMsg=`ls -1 ${INDIR}/../postponed | wc -l`
138        fi
139        if test $oldMsg != 0 ; then
140          newInD=`dirname $INDIR`
141          INDIR="$newInD/postponed"
142          echo " Change INDIR to '$INDIR' ($oldMsg old messages)"
143          oldMsg=1
144        fi
145    fi
146    
147    #-- check that $TEMPDIR exist (needed for STDOUT)
148    if test ! -d $TEMPDIR ; then
149        mkdir $TEMPDIR
150        RETVAL=$?
151        if test "x$RETVAL" != x0 ; then
152            date
153            echo "ERROR: directory \"$TEMPDIR\" doesn't exist and can't be created"
154            exit 4
155        fi
156  fi  fi
157    
158    
159  #---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|  #---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
160  #- 1) check that $INDIR is empty  if test $oldMsg = 0 ; then
161  nbMsg=`ls -1 $INDIR | wc -l`  
162  if test $nbMsg != 0 ; then  #- 1) check that $INDIR is empty (except .tar.gz files)
163      nbMsg=`ls -1 $INDIR | grep -v '\.tar\.gz$' | wc -l`
164      if test $nbMsg != 0 ; then
165      date      date
166      echo "ERROR: '$INDIR' is not empty ! --> exit"      echo "ERROR: '$INDIR' is not empty ! --> exit"
167      exit 4      exit 5
168  fi    fi
169    
170  nbMsg=0; ORIG=${RHOST}:$M_DIR    nbMsg=0; ORIG=${RHOST}:$M_DIR
171  #- 2) scp all msg from ORIG to INDIR  #- 2) scp all msg from ORIG to INDIR
172  cd $INDIR    cd $INDIR
173      scp -p ${RHOST}:$M_DIR/\* . > $STDOUT 2>&1      scp -p ${RHOST}:$M_DIR/msg.\* . > $STDOUT 2>&1
174      RETVAL=$?      RETVAL=$?
175      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
176       #echo " RETVAL='$RETVAL'"       #echo " RETVAL='$RETVAL'"
# Line 151  cd $INDIR Line 180  cd $INDIR
180          date          date
181          cat $STDOUT          cat $STDOUT
182          echo "ERROR: when trying to scp msg from $ORIG to $INDIR"          echo "ERROR: when trying to scp msg from $ORIG to $INDIR"
183          rm -f $STDOUT         #rm -f $STDOUT
184          exit 5          exit 6
185      fi      fi
186      rm -f $STDOUT      listMsg='' ; nbMsg=`ls -1 msg.* 2>/dev/null | wc -l`
     nbMsg=`ls -1 | wc -l`  
187      if test $nbMsg != 0 ; then      if test $nbMsg != 0 ; then
188          echo "> scp $nbMsg msg from '$ORIG' to '$INDIR'"          echo "> scp $nbMsg msg from '$ORIG' to '$INDIR'"
189          listMsg=`ls -1`          listMsg=`ls -1 msg.*`
190      fi          #- And rename msg by adding unique suffix
191  cd $HERE          for xx in $listMsg ; do
192  #echo " nbMsg='$nbMsg' ; listMsg='$listMsg'"            mv $xx $xx.$sufx
193            done
194        fi
195       #rm -f $STDOUT
196      cd $HERE
197      #echo " nbMsg='$nbMsg' ; listMsg='$listMsg'"
198    
199  #- 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)
200  if test $nbMsg != 0 ; then    if test $nbMsg != 0 ; then
201     #echo "ssh $RHOST cd $M_DIR \; /bin/rm -f $listMsg"     #echo "ssh $RHOST cd $M_DIR \; /bin/rm -f $listMsg"
202      ssh $RHOST cd $M_DIR \; /bin/rm -f $listMsg      ssh $RHOST cd $M_DIR \; /bin/rm -f $listMsg
203      RETVAL=$?      RETVAL=$?
204      if test "x$RETVAL" != x0 ; then      if test "x$RETVAL" != x0 ; then
205          echo "ERROR ( $RETVAL ) when trying to ssh+rm $nbMsg msg from $ORIG"          echo "ERROR ( $RETVAL ) when trying to ssh+rm $nbMsg msg from $ORIG"
206      #- note: Checking for return-value fron ssh command is not good enough,      #- note: Checking for return-value from ssh command is not good enough,
207      #        therefore we do not terminate if non-zero      #        therefore we do not terminate if non-zero
208         #exit 6        # exit 7
209      fi      fi
210  #- This is the log file that current "check_outp" (run on baudelaire) is checking:    #- This is the log file that "check_outp" (run on baudelaire) was checking:
211    logpfx="prc_emails_" ; sfx=`date +%m%d`    # logpfx="prc_emails_" ; sfx=`date +%m%d`
212    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"
213  #- update log-file to trigger a new "check_outp":    #- update log-file to trigger a new "check_outp":
214    if test -e  $logfile ; then touch $logfile ; fi    # if test -e  $logfile ; then touch $logfile ; fi
215  fi    fi
216  #echo 'Start processing msg locally'    #echo 'Start processing msg locally'
 #exit  
217    
218    fi
219  #---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|  #---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
220    #exit
221    
222  all_msg=`ls -1 $INDIR`  all_msg=`ls -1 $INDIR`
223  nb_msg=`echo "$all_msg" | grep -c '^msg\.'`  nb_msg=`echo "$all_msg" | grep -c '^msg\.'`
# Line 194  if test $PRT = 2 ; then Line 228  if test $PRT = 2 ; then
228    echo "Using OUTDIR=\"$OUTDIR\""    echo "Using OUTDIR=\"$OUTDIR\""
229    echo "Using INDIR=\"$INDIR\""    echo "Using INDIR=\"$INDIR\""
230    echo -n "Unpacking $nb_msg msg + $nb_tar tar-file ("`date`    echo -n "Unpacking $nb_msg msg + $nb_tar tar-file ("`date`
231      echo -n ", sfx=$sufx"
232    if test "x$ADDRERR" != x ; then    if test "x$ADDRERR" != x ; then
233       echo -n ", err: $ADDRERR"       echo -n ", err: $ADDRERR"
234    fi    fi
235    echo ")"    echo ")"
236  elif test $nb_files != 0 ; then  elif test $nb_files != 0 ; then
237    echo -n "Unpacking $nb_msg msg + $nb_tar tar-file ("`date`    echo -n "Unpacking $nb_msg msg + $nb_tar tar-file ("`date`
238      echo -n ", sfx=$sufx"
239    if test "x$ADDRERR" != x ; then    if test "x$ADDRERR" != x ; then
240       echo -n ", err: $ADDRERR"       echo -n ", err: $ADDRERR"
241    fi    fi
# Line 496  while [ $n -lt $Nbl ] ; do Line 532  while [ $n -lt $Nbl ] ; do
532                mail -s 'parse_emails err_4' $ADDRERR < $ERRMSG                mail -s 'parse_emails err_4' $ADDRERR < $ERRMSG
533                rm -f $ERRMSG                rm -f $ERRMSG
534              fi              fi
535                ( cd $INDIR ; mv -f $grpM ../postponed )
536              continue              continue
537            fi            fi
538          fi          fi

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.7

  ViewVC Help
Powered by ViewVC 1.1.22