| 35 | 
 BASEDIR="/u/u0/httpd/html/testing/results" | 
 BASEDIR="/u/u0/httpd/html/testing/results" | 
| 36 | 
 monthDir=`date +%Y`"_"`date +%m` | 
 monthDir=`date +%Y`"_"`date +%m` | 
| 37 | 
 OUTDIR= | 
 OUTDIR= | 
| 38 | 
 TEMPDIR=./ptmp | 
 TEMPDIR=/tmp/prc_emails | 
| 39 | 
  | 
 ERRMSG=/tmp/tmp.$$ | 
| 40 | 
 MUNPACK=munpack | 
 MUNPACK=munpack | 
| 41 | 
 ADDRERR= | 
 ADDRERR= | 
| 42 | 
 PRT=1 | 
 PRT=1 | 
| 116 | 
         date | 
         date | 
| 117 | 
         echo "ERROR: directory \"$OUTDIR\" doesn't exist and can't be created" | 
         echo "ERROR: directory \"$OUTDIR\" doesn't exist and can't be created" | 
| 118 | 
         exit 3 | 
         exit 3 | 
| 119 | 
  | 
     else | 
| 120 | 
  | 
         echo "Successfully created new dir: \"$OUTDIR\"" | 
| 121 | 
     fi | 
     fi | 
| 122 | 
     chgrp gcmpack $OUTDIR | 
     chgrp gcmpack $OUTDIR | 
| 123 | 
     chmod 775 $OUTDIR | 
     chmod 775 $OUTDIR | 
| 141 | 
  | 
  | 
| 142 | 
 for file in $all_files ; do | 
 for file in $all_files ; do | 
| 143 | 
  | 
  | 
| 144 | 
     #  create local copy | 
     #-- create local copy | 
| 145 | 
     test -e $TEMPDIR  &&  rm -rf $TEMPDIR | 
     test -e $TEMPDIR  &&  rm -rf $TEMPDIR | 
| 146 | 
     mkdir $TEMPDIR | 
     mkdir $TEMPDIR | 
| 147 | 
     RETVAL=$? | 
     RETVAL=$? | 
| 151 | 
     fi | 
     fi | 
| 152 | 
     if test "x$RETVAL" != x0 ; then | 
     if test "x$RETVAL" != x0 ; then | 
| 153 | 
       if test "x$ADDRERR" != x ; then | 
       if test "x$ADDRERR" != x ; then | 
| 154 | 
         echo "parsing email error" > tmp.$$ | 
         echo "parsing email error" > $ERRMSG | 
| 155 | 
         echo " processing file: '$INDIR/$file'" >> tmp.$$ | 
         echo " processing file: '$INDIR/$file'" >> $ERRMSG | 
| 156 | 
         echo -n "'mkdir $TEMPDIR' or 'cp $INDIR/$file $TEMPDIR'" >> tmp.$$ | 
         echo -n "'mkdir $TEMPDIR' or 'cp $INDIR/$file $TEMPDIR'" >> $ERRMSG | 
| 157 | 
         echo " returns error $RETVAL" >> tmp.$$ | 
         echo " returns error $RETVAL" >> $ERRMSG | 
| 158 | 
         mail -s 'parse_emails err_0' $ADDRERR < tmp.$$ | 
         mail -s 'parse_emails err_0' $ADDRERR < $ERRMSG | 
| 159 | 
         rm -f tmp.$$ | 
         rm -f $ERRMSG | 
| 160 | 
       fi | 
       fi | 
| 161 | 
       mv -f $INDIR"/"$file $INDIR"/../fail2process/"$file | 
       mv -f $INDIR"/"$file $INDIR"/../fail2process/"$file | 
| 162 | 
       continue | 
       continue | 
| 163 | 
     fi | 
     fi | 
| 164 | 
  | 
  | 
| 165 | 
     #  ignore multi-part messages | 
     #-- ignore multi-part messages | 
| 166 | 
     grep "Content-Type: message/partial" $INDIR"/"$file > /dev/null 2>&1 | 
     grep "Content-Type: message/partial" $INDIR"/"$file > /dev/null 2>&1 | 
| 167 | 
     RETVAL=$? | 
     RETVAL=$? | 
| 168 | 
     if test "x$RETVAL" = x0 ; then | 
     if test "x$RETVAL" = x0 ; then | 
| 169 | 
       if test "x$ADDRERR" != x ; then | 
       if test "x$ADDRERR" != x ; then | 
| 170 | 
         echo "parsing email error" > tmp.$$ | 
         echo "parsing email error" > $ERRMSG | 
| 171 | 
         echo 'grep "Content-Type: message/partial" returns error:' $RETVAL >> tmp.$$ | 
         echo 'grep "Content-Type: message/partial" returns error:' $RETVAL >> $ERRMSG | 
| 172 | 
         ls -l $INDIR"/"$file >> tmp.$$ | 
         ls -l $INDIR"/"$file >> $ERRMSG | 
| 173 | 
         mail -s 'parse_emails err_1' $ADDRERR < tmp.$$ | 
         mail -s 'parse_emails err_1' $ADDRERR < $ERRMSG | 
| 174 | 
         rm -f tmp.$$ | 
         rm -f $ERRMSG | 
| 175 | 
       fi | 
       fi | 
| 176 | 
       mv -f $INDIR"/"$file $INDIR"/../fail2process/"$file | 
       mv -f $INDIR"/"$file $INDIR"/../fail2process/"$file | 
| 177 | 
       continue | 
       continue | 
| 178 | 
     fi | 
     fi | 
| 179 | 
  | 
  | 
| 180 | 
     #  munpack | 
     #-- munpack | 
| 181 | 
     mun=`( cd $TEMPDIR ; $MUNPACK $file | cut -d ' ' -f 1 | head -1 )` | 
     mun=`( cd $TEMPDIR ; $MUNPACK $file | cut -d ' ' -f 1 | head -1 )` | 
| 182 | 
     RETVAL=$? | 
     RETVAL=$? | 
| 183 | 
     if test "x$RETVAL" != x0 ; then | 
     if test "x$RETVAL" != x0 ; then | 
| 184 | 
       if test "x$ADDRERR" != x ; then | 
       if test "x$ADDRERR" != x ; then | 
| 185 | 
         echo "parsing email error" > tmp.$$ | 
         echo "parsing email error" > $ERRMSG | 
| 186 | 
         echo "$MUNPACK $file returns error: $RETVAL" >> tmp.$$ | 
         echo "$MUNPACK $file returns error: $RETVAL" >> $ERRMSG | 
| 187 | 
         ls -l $INDIR"/"$file >> tmp.$$ | 
         ls -l $INDIR"/"$file >> $ERRMSG | 
| 188 | 
         mail -s 'parse_emails err_2' $ADDRERR < tmp.$$ | 
         mail -s 'parse_emails err_2' $ADDRERR < $ERRMSG | 
| 189 | 
         rm -f tmp.$$ | 
         rm -f $ERRMSG | 
| 190 | 
       fi | 
       fi | 
| 191 | 
       mv -f $INDIR"/"$file $INDIR"/../fail2process/"$file | 
       mv -f $INDIR"/"$file $INDIR"/../fail2process/"$file | 
| 192 | 
       continue | 
       continue | 
| 193 | 
     fi | 
     fi | 
| 194 | 
  | 
  | 
| 195 | 
     #  un-tar | 
     #-- un-tar | 
| 196 | 
     ( cd $TEMPDIR ; tar -xzvf $mun > out ) | 
     #( cd $TEMPDIR ; tar -xzvf $mun > out ) | 
| 197 | 
  | 
     #   to remove small files "._mydir" that some MAC OS are adding | 
| 198 | 
  | 
     #   (for each file or dir) to a tar-file, use option "--exclude=": | 
| 199 | 
  | 
     ( cd $TEMPDIR ; tar -xzvf $mun --exclude="._*" > out ) | 
| 200 | 
     RETVAL=$? | 
     RETVAL=$? | 
| 201 | 
     if test "x$RETVAL" != x0 ; then | 
     if test "x$RETVAL" != x0 ; then | 
| 202 | 
       if test "x$ADDRERR" != x ; then | 
       if test "x$ADDRERR" != x ; then | 
| 203 | 
         echo "parsing email error" > tmp.$$ | 
         echo "parsing email error" > $ERRMSG | 
| 204 | 
         echo "tar -xzvf $mun returns error:" $RETVAL >> tmp.$$ | 
         echo "tar -xzvf $mun returns error:" $RETVAL >> $ERRMSG | 
| 205 | 
         ls -l $INDIR"/"$file >> tmp.$$ | 
         ls -l $INDIR"/"$file >> $ERRMSG | 
| 206 | 
         ls -l $mun >> tmp.$$ | 
         ls -l $mun >> $ERRMSG | 
| 207 | 
         mail -s 'parse_emails err_3' $ADDRERR < tmp.$$ | 
         mail -s 'parse_emails err_3a' $ADDRERR < $ERRMSG | 
| 208 | 
         rm -f tmp.$$ | 
         rm -f $ERRMSG | 
| 209 | 
       fi | 
       fi | 
| 210 | 
       mv -f $INDIR"/"$file $INDIR"/../fail2process/"$file | 
       mv -f $INDIR"/"$file $INDIR"/../fail2process/"$file | 
| 211 | 
       continue | 
       continue | 
| 212 | 
     fi | 
     fi | 
| 213 | 
     tdir=`cat $TEMPDIR"/out" | head -1 | sed -e 's|^./||g' | cut -d '/' -f 1` | 
     tdir=`cat $TEMPDIR"/out" | head -1 | sed -e 's|^./||g' | cut -d '/' -f 1` | 
| 214 | 
     rm -f $TEMPDIR"/out" | 
    #tdir=`( cd $TEMPDIR ; /bin/ls -l | grep '^d' | head -1 | awk '{print $NF}' )` | 
| 215 | 
  | 
     if test -d $TEMPDIR/$tdir ; then | 
| 216 | 
  | 
       rm -f $TEMPDIR"/out" | 
| 217 | 
  | 
     else | 
| 218 | 
  | 
       if test "x$ADDRERR" != x ; then | 
| 219 | 
  | 
         echo "parsing email error" > $ERRMSG | 
| 220 | 
  | 
         echo " fail to get a dir output name 'tdir=$tdir'" >> $ERRMSG | 
| 221 | 
  | 
         echo " from tar file '$TEMPDIR/$mun'" >> $ERRMSG | 
| 222 | 
  | 
         mail -s 'parse_emails err_3b' $ADDRERR < $ERRMSG | 
| 223 | 
  | 
         rm -f $ERRMSG | 
| 224 | 
  | 
       fi | 
| 225 | 
  | 
       mv -f $INDIR"/"$file $INDIR"/../fail2process/"$file | 
| 226 | 
  | 
       continue | 
| 227 | 
  | 
     fi | 
| 228 | 
  | 
  | 
| 229 | 
     #  select which Monthly Output Dir: | 
     #-- select which Monthly Output Dir: | 
| 230 | 
     locDir=$OUTDIR | 
     locDir=$OUTDIR | 
| 231 | 
     if test "x$monthDir" != x0 ; then | 
     if test "x$monthDir" != x0 ; then | 
| 232 | 
       dd=`echo $tdir | sed 's/_/ /g' | awk '{ for(i=1;i<=NF;i++) print $i }'\ | 
       dd=`echo $tdir | sed 's/_/ /g' | awk '{ for(i=1;i<=NF;i++) print $i }'\ | 
| 242 | 
         if test ! -d $locDir ; then | 
         if test ! -d $locDir ; then | 
| 243 | 
           if test $PRT = 2 ; then echo "NO DIR: '$locDir' => '$tdir' POSTPONED" ; fi | 
           if test $PRT = 2 ; then echo "NO DIR: '$locDir' => '$tdir' POSTPONED" ; fi | 
| 244 | 
           if test "x$ADDRERR" != x ; then | 
           if test "x$ADDRERR" != x ; then | 
| 245 | 
             echo "parsing email error" > tmp.$$ | 
             echo "parsing email error" > $ERRMSG | 
| 246 | 
             echo "no dir '$locDir' for outp. '$tdir'" > tmp.$$ | 
             echo "no dir '$locDir' for outp. '$tdir'" > $ERRMSG | 
| 247 | 
             ls -l $INDIR"/"$file >> tmp.$$ | 
             ls -l $INDIR"/"$file >> $ERRMSG | 
| 248 | 
             mail -s 'parse_emails err_4' $ADDRERR < tmp.$$ | 
             mail -s 'parse_emails err_4' $ADDRERR < $ERRMSG | 
| 249 | 
             rm -f tmp.$$ | 
             rm -f $ERRMSG | 
| 250 | 
           fi | 
           fi | 
| 251 | 
           continue | 
           continue | 
| 252 | 
         fi | 
         fi | 
| 254 | 
       fi | 
       fi | 
| 255 | 
     fi | 
     fi | 
| 256 | 
  | 
  | 
| 257 | 
     #  copy to $locDir and rename if necessary | 
     #-- copy to $locDir and rename if necessary | 
| 258 | 
     sdir=$tdir | 
     sdir=$tdir | 
| 259 | 
     if test -e $locDir"/"$tdir ; then | 
     if test -e $locDir"/"$tdir ; then | 
| 260 | 
         ad=0 | 
         ad=0 | 
| 273 | 
     RETVAL=$? | 
     RETVAL=$? | 
| 274 | 
     if test "x$RETVAL" != x0 ; then | 
     if test "x$RETVAL" != x0 ; then | 
| 275 | 
       if test "x$ADDRERR" != x ; then | 
       if test "x$ADDRERR" != x ; then | 
| 276 | 
         echo "parsing email error" > tmp.$$ | 
         echo "parsing email error" > $ERRMSG | 
| 277 | 
         echo "mv $TEMPDIR/$tdir $locDir/$sdir returns error:" $RETVAL >> tmp.$$ | 
         echo "mv $TEMPDIR/$tdir $locDir/$sdir returns error:" $RETVAL >> $ERRMSG | 
| 278 | 
         echo -n "in dir: $TEMPDIR : " ; ls -l $TEMPDIR  >> tmp.$$ | 
         echo -n "in dir: $TEMPDIR : " ; ls -l $TEMPDIR  >> $ERRMSG | 
| 279 | 
         echo -n "in dir: $OUTDIR : " ; ls -l $locDir  >> tmp.$$ | 
         echo -n "in dir: $OUTDIR : " ; ls -l $locDir  >> $ERRMSG | 
| 280 | 
         mail -s 'parse_emails err_5' $ADDRERR < tmp.$$ | 
         mail -s 'parse_emails err_5' $ADDRERR < $ERRMSG | 
| 281 | 
         rm -f tmp.$$ | 
         rm -f $ERRMSG | 
| 282 | 
       fi | 
       fi | 
| 283 | 
       mv -f $INDIR"/"$file $INDIR"/../fail2process/"$file | 
       mv -f $INDIR"/"$file $INDIR"/../fail2process/"$file | 
| 284 | 
       continue | 
       continue | 
| 285 | 
     fi | 
     fi | 
| 286 | 
     chmod -R a+rx $locDir"/"$sdir > /dev/null 2>&1 | 
     chmod -R a+rx $locDir"/"$sdir > /dev/null 2>&1 | 
| 287 | 
  | 
  | 
| 288 | 
     #  remove the original file | 
     #-- remove the original file | 
| 289 | 
     rm -f $INDIR"/"$file | 
     rm -f $INDIR"/"$file | 
| 290 | 
  | 
  | 
| 291 | 
 done | 
 done |