>>>>> "SKS" == S K Singh <[EMAIL PROTECTED]> writes:
SKS> I wish to copy a mail to all users of my server in one stroke
SKS> without giving individual addresses
I use the following little bit of Perl. It can exempt certain UIDs and
users along with those having shells not in /etc/shells.
--
Jason L Tibbitts III - [EMAIL PROTECTED] - 713/743-3486 - 660PGH - 94 PC800
System Manager: University of Houston Department of Mathematics
"You'll see the blood as we roll in it together..."
#!/usr/local/bin/perl
#
# mailall
#
# sends mail to all users on this host. verifies that the user is really
# a user by checking uid, shell, and login name. allows us to send mail
# to, for example, "[EMAIL PROTECTED]" and delievers that
# mail to all the "real" people on that machine.
#
# requires a line in /usr/lib/aliases like:
# allusers: "|/usr/local/bin/mailall"
#
# Originally By: [EMAIL PROTECTED]
# October 15, 1992
# Hacked, mangled, and rewritten by
# Jason L. Tibbitts <[EMAIL PROTECTED]>
# Set this for testing
$DEBUG = 0;
# Ignore all users with IDs less than this
$MIN_ID = 1000;
# Where to find list of shells
$ETC_SHELLS = "/etc/shells";
# These users will not be sent mail
@nomail = qw(
dumpuser
flacs
fec
help
nobody
noacess
tester
);
# Grab the list of valid shells; users without a valid shell will get no
# mail
open(SHELLS,$ETC_SHELLS) ||
die("Can't open list of valid shells: $ETC_SHELLS, $!, stopped");
@shells = <SHELLS>;
close SHELLS;
# Go through the password file and find real users
#open(PASSWD,$ETC_PASSWD) || die ("Can't open password file: $ETC_PASSWD: $!,
stopped");
while (1) {
($login,$dummy,$uid,$dummy,
$dummy,$dummy,$dummy,$dummy,$shell) = getpwent;
# ($login,$dummy,$uid,$dummy,$dummy,$dummy,$shell) = split(/:/);
last unless $login;
push(@mailto,$login) if ($uid >= $MIN_ID &&
grep(/^$shell$/,@shells) &&
$shell !~ /^$/) &&
!grep(/^$login$/,@nomail);
}
#close PASSWD;
if ($DEBUG) {
print "Will send mail to these users:\n";
foreach (@mailto) {
print "$_\n";
}
exit 0;
}
# Dump standard input into a message sent to all valid users
open (MAIL,"|/usr/lib/sendmail @mailto");
foreach (<STDIN>) {
print MAIL;
}
close MAIL;
-
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to [EMAIL PROTECTED]