source: SH_SHM/trunk/util/shm_exec_read_adrm_mail.csh @ 92

Revision 92, 1.6 KB checked in by marcus, 14 years ago (diff)

r74 | svn | 2009-01-20 15:46:47 +0100 (Di, 20 Jan 2009) | 1 line

changed mailx qualifiers due to change in syntax

  • Property svn:executable set to *
Line 
1#! /bin/csh
2#
3# file shm_exec_read_adrm_mail.csh
4#      ===========================
5#
6# version 1, 15-Jan-2002
7#
8# Extracts AutoDRM mail from mail file
9# K. Stammler, 15-Jan-2002
10
11if  ("$4" == "")  then
12        echo "Usage: $0 <msgid> <mailfile> <waittime> <outfile> [<mailhost>]"
13        exit
14endif
15
16#set echo
17
18# get parameters
19set msgid="$1"
20set mailfile=$2
21set wait=$3
22set outfile=$4
23set mailhost=$5
24
25# set constants
26set tmpfile=$SH_SCRATCH/mr-$$.000
27
28if  ("$mailhost" == "")  then
29        if  (! -e $mailfile)  then
30                echo "$0 : mailfile $mailfile not found.  Abort."
31                exit
32        endif
33endif
34
35# wait for 'wait' loops for the message to arrive
36set wcnt=0
37while  (1 > 0)
38
39        if  (-e $outfile)  \rm $outfile
40
41        @ wcnt = $wcnt + 1
42        if  ($wcnt > $wait)  then
43                echo "AutoDRM response mail not found.  Automatic read not possible."
44                if  (-e $outfile)  \rm $outfile
45                exit
46        endif
47
48        echo "waiting for 15 seconds ($wcnt) ..."
49        sleep 15
50
51        if  ("$mailhost" == "")  then
52                set res=`mailx -H -f $mailfile | grep -i autodrm | tail -1`
53        else
54                set res=`ssh $mailhost mailx -H -f $mailfile | grep -i autodrm | tail -1`
55        endif
56        if  ($#res < 3)  continue
57
58        set num=$res[2]
59        if  (-e $tmpfile)  \rm $tmpfile
60        touch $tmpfile
61        echo "$num"  >>$tmpfile
62        echo "q"     >>$tmpfile
63        if  ("$mailhost" == "")  then
64                mailx -N -f $mailfile <$tmpfile >$outfile
65        else
66                ssh $mailhost mailx -N -f $mailfile <$tmpfile >$outfile
67        endif
68        \rm $tmpfile
69
70        set res=`grep "MSG_ID $msgid SHMREQ" $outfile`
71        if  ("$res" == "")  then
72                set res=`grep "REF_ID $msgid SHMREQ" $outfile`
73        endif
74        if  ("$res" == "")  then
75                echo "wrong file found, delete output file"
76                \rm $outfile
77        else
78                # output file created and now exit to read
79                exit
80        endif
81
82end
Note: See TracBrowser for help on using the repository browser.