/[MITgcm]/mitgcm.org/front_content/parse_emails
ViewVC logotype

Annotation of /mitgcm.org/front_content/parse_emails

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


Revision 1.9 - (hide annotations) (download)
Fri Nov 30 00:45:55 2007 UTC (17 years, 7 months ago) by jmc
Branch: MAIN
Changes since 1.8: +3 -3 lines
comment out gzip of unexisting output.txt

1 edhill 1.1 #! /usr/bin/env bash
2    
3 jmc 1.9 # $Header: /u/gcmpack/mitgcm.org/front_content/parse_emails,v 1.8 2007/11/29 23:55:56 jmc Exp $
4 edhill 1.1 #
5     # The purpose of this script is to parse the emails produced by the
6     # MITgcm/verificaton/testreport script and store the data in a
7     # reasonable location.
8    
9    
10     usage()
11     {
12     echo
13     echo "Usage: $0 [OPTIONS]"
14     echo
15     echo "where possible OPTIONS are:"
16     echo " (-help|-h) print usage"
17     echo " (-ind |-i )DIR get mpack-created emails from DIR"
18     echo " [def=\"$INDIR\"]"
19     echo " (-outd |-o )DIR write the data to DIR"
20     echo " [def=\"$OUTDIR\"]"
21     echo " (-tempd |-t )DIR use temporary directory DIR"
22     echo " [def=\"$TEMPDIR\"]"
23     echo
24     exit 1
25     }
26    
27     # defaults
28     INDIR="/u/edhill/Mail/MITgcm-test"
29     OUTDIR=
30     TEMPDIR=./ptmp
31 edhill 1.7 MUNPACK=/u/edhill/local/bin/munpack
32 edhill 1.1
33     # Parse options
34     ac_prev=
35     for ac_option ; do
36    
37     # If the previous option needs an argument, assign it.
38     if test -n "$ac_prev"; then
39     eval "$ac_prev=\$ac_option"
40     ac_prev=
41     continue
42     fi
43    
44     ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
45    
46     case $ac_option in
47    
48     -help | --help | -h | --h)
49     usage ;;
50    
51     -ind | --ind | -i | --i)
52     ac_prev=INDIR ;;
53     --ind=* | -ind=* | --i=* | -i=*)
54     INDIR=$ac_optarg ;;
55    
56     -outd | --outd | -o | --o)
57     ac_prev=OUTDIR ;;
58     --outd=* | -outd=* | --o=* | -o=*)
59     OUTDIR=$ac_optarg ;;
60    
61     -tempd | --tempd | -t | --t)
62     ac_prev=TEMPDIR ;;
63     --tempd=* | -tempd=* | --t=* | -t=*)
64     TEMPDIR=$ac_optarg ;;
65    
66     *)
67     # copy the file list to FL_#
68     echo "Error: don't understand argument \"$ac_option\""
69     usage
70     ;;
71    
72     esac
73    
74     done
75    
76     if test "x$OUTDIR" = x ; then
77     OUTDIR="/u/u0/httpd/html/testing/results/"`date +%Y`"_"`date +%m`
78     fi
79     if test ! -e $OUTDIR ; then
80     mkdir $OUTDIR
81     RETVAL=$?
82     if test "x$RETVAL" = x ; then
83     echo "ERROR: directory \"$OUTDIR\" doesn't exist and can't be created"
84     exit 1
85     fi
86 jmc 1.8 chgrp gcmpack $OUTDIR
87     chmod 775 $OUTDIR
88 edhill 1.1 fi
89    
90     echo "Using OUTDIR=\"$OUTDIR\""
91     echo "Using INDIR=\"$INDIR\""
92    
93     all_files=`ls -1 $INDIR`
94    
95     echo -n "Unpacking the emails ..."
96     for file in $all_files ; do
97    
98     # create local copy
99 edhill 1.2 test -e $TEMPDIR && rm -rf $TEMPDIR
100 edhill 1.1 mkdir $TEMPDIR
101     cp $INDIR"/"$file $TEMPDIR
102    
103     # ignore multi-part messages
104     grep "Content-Type: message/partial" $INDIR"/"$file > /dev/null 2>&1
105     RETVAL=$?
106     if test "x$RETVAL" = x0 ; then
107     continue
108     fi
109    
110     # munpack
111     mun=`( cd $TEMPDIR ; $MUNPACK $file | cut -d ' ' -f 1 | head -1 )`
112     RETVAL=$?
113     if test "x$RETVAL" != x0 ; then
114     continue
115     fi
116    
117     # un-tar
118     ( cd $TEMPDIR ; tar -xzvf $mun > out )
119     RETVAL=$?
120     if test "x$RETVAL" != x0 ; then
121     continue
122     fi
123 edhill 1.2 tdir=`cat $TEMPDIR"/out" | head -1 | sed -e 's|^./||g' | cut -d '/' -f 1`
124 edhill 1.1 rm -f $TEMPDIR"/out"
125    
126     # copy to $OUTDIR and rename if necessary
127     if test -e $OUTDIR"/"$tdir ; then
128     ad=0
129     while test -e $OUTDIR"/"$tdir"_"$ad ; do
130     ad=$(( $ad + 1 ))
131     done
132 edhill 1.6 mv $TEMPDIR"/"$tdir $OUTDIR"/"$tdir"_"$ad > /dev/null 2>&1
133 edhill 1.5 chmod -R a+rx $OUTDIR"/"$tdir"_"$ad > /dev/null 2>&1
134 jmc 1.9 # gzip $OUTDIR"/"$tdir"_"$ad"/output.txt"
135 edhill 1.1 else
136 edhill 1.6 mv $TEMPDIR"/"$tdir $OUTDIR > /dev/null 2>&1
137 edhill 1.5 chmod -R a+rx $OUTDIR"/"$tdir > /dev/null 2>&1
138 jmc 1.9 # gzip $OUTDIR"/"$tdir"/output.txt"
139 edhill 1.1 fi
140    
141     # remove the original file
142     rm -f $INDIR"/"$file
143    
144     done
145     echo " done"
146    
147 edhill 1.5 # echo -n "gzipping all the \"output.txt\" files ..."
148     # (
149     # cd $OUTDIR
150     # outp=`find . -name output.txt`
151     # if test "x$outp" != x ; then
152     # gzip $outp
153     # fi
154     # )
155     # echo " done"
156    
157     # echo -n "setting permissions to world-readable ..."
158     # chmod -R a+rx $OUTDIR > /dev/null 2>&1
159     # echo " done"
160 edhill 1.1
161    

  ViewVC Help
Powered by ViewVC 1.1.22