/[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.5 by jmc, Sat Jan 13 16:26:20 2018 UTC revision 1.6 by jmc, Sat Feb 3 15:52:10 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_$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-|--+----|
# 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        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=$?
# Line 141  if test ! -d $TEMPDIR ; then Line 153  if test ! -d $TEMPDIR ; then
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
# Line 169  cd $INDIR Line 185  cd $INDIR
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=$?
# Line 185  if test $nbMsg != 0 ; then Line 205  if test $nbMsg != 0 ; then
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\.'`
# Line 205  if test $PRT = 2 ; then Line 226  if test $PRT = 2 ; then
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
# Line 507  while [ $n -lt $Nbl ] ; do Line 530  while [ $n -lt $Nbl ] ; do
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

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

  ViewVC Help
Powered by ViewVC 1.1.22