Great Circle Associates Majordomo-Users
(October 1997)
 

Indexed By Date: [Previous] [Next] Indexed By Thread: [Previous] [Next]

Subject: Re: list population script
From: Jason L Tibbitts III <tibbs @ hpc . uh . edu>
Date: 12 Oct 1997 01:05:51 -0500
To: Michael Lausin <soscc @ yampa . cmn . net>
Cc: majordomo-users @ GreatCircle . COM
In-reply-to: Michael Lausin's message of Sat, 11 Oct 1997 22:47:40 -0600 (MDT)
References: <Pine.BSI.3.95.971011224610.23699C-100000@yampa.cmn.net>

>>>>> "ML" == Michael Lausin <soscc@yampa.cmn.net> writes:

ML> Is there a script running around that will take the password file and
ML> yank all of the user ids out of it for creating a listname file?

cat /etc/passwd | awk -F: '{print $1}'

It's probably better to do this on the fly, so the list doesn't get out of
date.  Here's a script I use; it sits at an alias and sends mail to
everybody except those who have invalid shells or who are in a special
list.  You could put this at the outgoing alias instead of the :include:
and it would probably work.

#!/usr/local/bin/perl
#
# mailall
#
# sends mail to all users on this host.  verifies that the user is really
# a user by checking Cid, shell, and login name.  allows us to send mail
# to, for example, "allusers@mother.cs.colorado.edu" 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: davewood@cs.colorado.edu
#     October 15, 1992
# Hacked, mangled, and rewritten by
#     Jason L. Tibbitts <tibbs@hpc.uh.edu>


# 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;

 - J<


References:
Indexed By Date Previous: list population script
From: Michael Lausin <soscc@yampa.cmn.net>
Next: Re: mungedomain
From: Jason L Tibbitts III <tibbs@hpc.uh.edu>
Indexed By Thread Previous: list population script
From: Michael Lausin <soscc@yampa.cmn.net>
Next: Re: list population script
From: Daniel Garcia <dgarcia@hollyfeld.org>

Google
 
Search Internet Search www.greatcircle.com