blob: 846914edc13f50fcddad1ed86838c1e87367d106 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
#! @SH@
# Mail a list of files, as they are.
# Copyright (C) 1990, 1995, 2005 Free Software Foundation, Inc.
# François Pinard <pinard@iro.umontreal.ca>, 1991.
package="@PACKAGE@"
version="@VERSION@"
progname=`echo $0 | sed -e 's,.*/,,'`
usage()
{
if test $# -gt 0
then
exec >&2
echo "$*"
fi
cat <<- _EOF_
Usage: $progname [OPTION] DESTIN TYPE SUBJECT FILE ...
Where:
OPTION is:
--help display this help and exit
--version output version information and exit
-x trace script
DESTIN is a list of email addresses
TYPE is a subject introduction word or short phrase
SUBJECT is a longer description of the contents
FILE ... is a list of files to send
_EOF_
exit $#
}
SLEEP=2
### Decode the options.
while test $# -gt 0
do
case $1 in
-x) trace=-x; set -x; shift ;;
--v* ) echo "$progname - $package $version"; exit 0 ;;
--h* | \
'-?' ) usage ;;
--) shift ; break ;;
-*) usage "'$1' is an unknown option" ;;
*) break
esac
done
test $# -ge 4 || usage "Too few arguments."
destin="$1"; shift
type="$1"; shift
subject="$1"; shift
maxcount=$#
files="$*"
for f in ${files}
do test -f ${f} || usage "Error: \`$f' is not a file" ; done
### Mail all files, making a proper subject for each message.
( if [ -f $destin ]; then
cat $destin
else
echo $destin
fi
) | (
total=0
while read destin; do
count=0
for file in $files; do
count=`expr $count + 1`
if [ $maxcount = 1 ]; then
string="$type"
else
string="$type ($count/$maxcount)"
fi
echo "Mailing $string to $destin"
[ $total -ne 0 ] && sleep $SLEEP
@MAILER@ -s "$string: $subject" $destin < $file
total=`expr $total + 1`
[ $count -lt $maxcount ] && sleep $SLEEP
done
done
if [ $total -eq 0 ]; then
echo 'No message queued'
elif [ $total -eq 1 ]; then
echo 'Message queued'
else
echo "$count messages queued"
fi
)
exit 0
## Local Variables:
## mode: shell-script
## tab-width: 8
## indent-tabs-mode: nil
## sh-indentation: 2
## sh-basic-offset: 2
## End:
##
## end of get-incidents.sh
|