SEX! or, how do I mail to a lot of unix users?

Jason C Austin jason at cs.odu.edu
Fri Jun 1 06:32:42 AEST 1990


In article <900531083002.30e0d06c at Csa2.LBL.Gov> thermal%solgel.hepnet at CSA2.LBL.GOV writes:
-> I would like to be able to send a mail message to all the users on
-> a unix machine.  Of course, I could do it the long way, that is,
-> do a 'finger' or 'who', thus getting a list of all the users, and
-> then sending a mail message to each, one at a time.  Is there a
-> quicker way? (it seems to me there could be two or three different
-> ways, such as setting up a mailing list, or some nifty command that
-> will do this on one stroke of the finger).  Obviously, I'm not a
-> unix guru or wizard, so make your explanation understandable, please.
-> 
-> Thanks, Dana

	That would depend on what type of message that you want to
send.  You can send an online to everyone currently logged in using
the ``wall'' command.  If you're trying to send mail to everyone, one
way would be to build a list of users and have a shell script send
your mail to everyone.  The following scripts would send mail to
everyone if you have your list of users in a file called user-list.

#!/bin/sh

users=`cat user-list`

for user in $users
 do
  echo "Mailing $user"
  mail $user < message
 done
	

	Just a little warning about mass mailing like this.  It tends
to put a large load on the mail handler, especially if you're mailing
a large file, so if you're mailing to a lot of people, you will
probably want to break them down into small groups.

--
Jason C. Austin
jason at cs.odu.edu



More information about the Comp.unix.questions mailing list