> mail `awk -F: '{ print $1 }' /etc/passwd`
>To just send to normal users (which is I think what was asked)
>mail `awk -F: '$3>199 && $3<10000 {print $1}' /etc/passwd`
>(The specific numbers may vary on some systems but on ours normal
>user numbers start at 200.)
On my system (Sun 4/690, SunOS 4.1.2, wc -l /etc/passwd => 2500), this
will give "too many arguments". Also, on my system this approach will
drive the load average through the roof and make the system unusably
slow. Mail simply starts sendmail working on the message and returns
immediately, so you'll have hundreds (if not thousands) of sendmail
processes all competeing for the same system resources dumped onto
your system.
If you set "sendwait" before calling mail, mail will wait until
sendmail finishes before returning, so that you will only have one
sendmail process running at a time.
I remind my users that *news* is designed to send the same message to
many people - only one copy is saved per site, and minimal storing and
forwarding is done. Mail is very inefficient when sending the same
message to many people, because each person gets their own copy,
separately stored and processed.
However, there are times when you realy do want to send the same
message as mail to many people. In that situation, I use the
following script:
----------------------------------------------------------------------
#!/bin/sh
# usage:
# bulkmail message list 'This is the Subject'
#
# "message" is the name of the file that contains the body of the
# message.
#
# "list" is the name of a file which contains the addresses, one per
# line
#
# The third argument is the subject. The subject should be put in
# quotes so that it is all one argument. You may have to escape some
# special characters.
if [ $# != 3 ]
then
echo usage: bulkmail message list \'This is the subject\'
exit 1
fi
sendwait=true
export sendwait
while read address
do
/usr/ucb/mail -s "$3" $address < $1
done < $2
----------------------------------------------------------------------
School of Engineering and Applied Science
University of Pennsylvania