Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Feb 1997 14:44:53 -0600
From:      Edwin Culp <eculp@mexcom.net>
To:        Chris Shenton <chris@absinthe.i3inc.com>
Cc:        isp@freebsd.org
Subject:   Re: Script to send mail to all users?
Message-ID:  <330B6645.56B25411@mexcom.net>
References:  <199702191758.UAA12437@magrathea.chance.ru> <199702191927.OAA20877@absinthe.i3inc.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Chris Shenton wrote:
> 
> Thanks for the suggestions. Some iterated on the users, one message
> per user; another cut the names and submitted that as part of the
> command but I was concerned that the recipients would see all the
> usernames and that the command line might be too long; a couple
> suggested Qualcomm's pop bulletin board.
> 
> I finally went with a little program which used awk to create a file
> with all users, then modifying /etc/aliases to use this. This avoids
> users having to see thousands of names on the To: line, sending
> multiple messages, and long command (or /etc/aliases) lines; it also
> allows us to use whatever mail client to send the message, rather than
> putting a message in a file.
> 
> It requires that you generate the new list of aliases to ensure the
> list is current, but it's trivial. FYI, here's what I did:
> 
> /etc/aliases:
> 
> allusers:       :include:/etc/aliases.allusers
> 
> /usr/local/bin/makeallusers:
> 
> #!/bin/sh
> # $Id: makeallusers,v 1.1 1997/02/19 19:20:56 chris Exp $
> #
> # Create a list of all (real) users, one per line, to be used as a
> # mail alias via an :include: directive.
> ###############################################################################
> 
> cat /etc/passwd | awk -F':' '{print $1}' | egrep -v '^(root|toor|daemon|operator|bin|games|news|man|uucp|xten|nobody|ftp)$' > /etc/aliases.allusers
A little easier:
awk -F':'
'!/^root|toor|daemon|operator|bin|games|news|man|uucp|xten|nobody|ftp/{print
$1}' /etc/passwd > /etc/aliases.allusers
easier:
awk -F':' '$3>100{print $1}' /etc/passwd > /etc/aliases.allusers
Without alias:
	for i in `awk -F':' '$3>100{print $1}' /etc/passwd`
		do 
		mail -s "Your Subject" $i <<%
		You can put you message
		en this space and can even
		use shell variables, executables, etc.
		%
	done

Ed



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?330B6645.56B25411>