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

Contents of /mitgcm.org/front_content/parse_emails

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


Revision 1.8 - (show annotations) (download)
Thu Nov 29 23:55:56 2007 UTC (17 years, 7 months ago) by jmc
Branch: MAIN
Changes since 1.7: +3 -1 lines
change results dir. group to gcmpack and give writing permission to the group

1 #! /usr/bin/env bash
2
3 # $Header: /u/gcmpack/mitgcm.org/front_content/parse_emails,v 1.7 2006/10/12 01:51:09 edhill Exp $
4 #
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 MUNPACK=/u/edhill/local/bin/munpack
32
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 chgrp gcmpack $OUTDIR
87 chmod 775 $OUTDIR
88 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 test -e $TEMPDIR && rm -rf $TEMPDIR
100 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 tdir=`cat $TEMPDIR"/out" | head -1 | sed -e 's|^./||g' | cut -d '/' -f 1`
124 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 mv $TEMPDIR"/"$tdir $OUTDIR"/"$tdir"_"$ad > /dev/null 2>&1
133 chmod -R a+rx $OUTDIR"/"$tdir"_"$ad > /dev/null 2>&1
134 gzip $OUTDIR"/"$tdir"_"$ad"/output.txt"
135 else
136 mv $TEMPDIR"/"$tdir $OUTDIR > /dev/null 2>&1
137 chmod -R a+rx $OUTDIR"/"$tdir > /dev/null 2>&1
138 gzip $OUTDIR"/"$tdir"/output.txt"
139 fi
140
141 # remove the original file
142 rm -f $INDIR"/"$file
143
144 done
145 echo " done"
146
147 # 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"

  ViewVC Help
Powered by ViewVC 1.1.22