[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [cobalt-users] Can I Easily Send All Users On Raq2 An Email Message?
- Subject: RE: [cobalt-users] Can I Easily Send All Users On Raq2 An Email Message?
- From: "Jimmy Gross" <jimmy@xxxxxxxxxxxxxxx>
- Date: Thu Oct 26 17:16:02 2000
- List-id: Mailing list for users to share thoughts on Cobalt products. <cobalt-users.list.cobalt.com>
Sending mail to ALL users
Occasionally, you need to send messages to all users on your system, Warning
users of planning downtime for hardware upgrades is a good example. Sending
email to each user individually is extremely time consuming and wasteful;
this is precisely the kind of task that email aliases and mailing lists were
invented for. Keeping a mailing list of all the users on your system can be
problematic, however. If you are not diligent about keeping the mailing list
current, it will become increasingly inaccurate as you add and delete users.
Also, if your system has many users, the mere size of the alias list can
become unwieldy.
The following script, called mailfile, provides a simple method of working
around these problems. It grabs the login names directly from the
/etc/passwd file and sends email to all the users.
#!/bin/csh
#
# mailfile: This script mails the specified file to all users of the system.
# It skips the first 17 accounts so we do not send email to system accounts
like 'root'.
#
# USAGE: mailfile "Subject goes here" filename.txt
#
# Check for a subject
#
if ( 'echo $1 | awk '{ print $1 }'` =="" ) then
echo you do not supply a subject for the message.
echo be sure to enclose it in quotes
exit 1
else
# Get the subject of the message
set subject=$1
endif
#
# Check for a filename
#
if ( $2 =="" ) then
echo you did not supply a file name
exit 2
else
# Get the name of the file to send
set filename=$2
endif
#
# Check that the file exists
#
if ( -f $filename ) then
Echo Sending file $filename
else
echo File does not exist
exit 3
endif
#
# Loop through every login name. but skip the first 17 accounts
#
for each user (`awk -f: '{ print $1 }' /etc/passwd | tail +17`)
# Mail the file
echo Mailing to $user
mail -s "$subject" $user < $filename
# sleep for a few seconds so we don't overload the mailer
# On fast systems or systems with few accounts, you can
# probably take this delay out.
sleep 2
end
The script accepts two parameters. The first subject of the email message,
which is enclosed in quotes. The second is the name of the file containing
the text message to send. Thus, to send an email message to all users
warning them about upcoming server hardware upgrades, I might to something
similar to the following.
mailfile "System upgrade at 5:00pm" upgrade.txt
The file upgrade.txt contains the text of the message to be sent to each
user. The really useful thing about this approach is that I can save this
text file and easily modify and resend it the next time I upgrade the
system.
Tip: If your users login to your system using text-based logins instead of
graphical logins, you can add messages to the /etc/motd file to have them
reach your users. Any text in that file will be displayed on each user;s
screen after the user logs in and before the first shell prompt appears.
From the Linux Bible.
jimmy
-----Original Message-----
From: cobalt-users-admin@xxxxxxxxxxxxxxx
[mailto:cobalt-users-admin@xxxxxxxxxxxxxxx]On Behalf Of Larry Hennessee
Sent: Wednesday, October 25, 2000 12:58 PM
To: cobalt-users@xxxxxxxxxxxxxxx
Subject: [cobalt-users] Can I Easily Send All Users On Raq2 An Email
Message?
I'd like to send all users on my RAQ2, about 50 virtual domains, email
messages on a weekly basis. Can I do this with a TELNET command? Can anyone
make a suggestion?
Larry Hennessee
larry@xxxxxxxxxxxxxxx
_______________________________________________
cobalt-users mailing list
cobalt-users@xxxxxxxxxxxxxxx
To Subscribe or Unsubscribe, please go to:
http://list.cobalt.com/mailman/listinfo/cobalt-users