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

Geoff Coleman geoff at edm.uucp
Thu Jun 7 06:26:59 AEST 1990


>From article <804 at ehviea.ine.philips.nl>, by leo at ehviea.ine.philips.nl (Leo de Wit):
-> In article <1990May31.230138.14896 at iwarp.intel.com> merlyn at iwarp.intel.com (Randal Schwartz) writes:
-> |In article <JASON.90May31163242 at aelle.cs.odu.edu>, jason at cs (Jason C Austin) writes:
-> || #!/bin/sh
-> || 
-> || users=`cat user-list`
-> 
-> 1 fork, 1 exec.
-> 
-> || 
-> || for user in $users
-> ||  do
-> ||   echo "Mailing $user"
-> ||   mail $user < message
-> ||  done
-> |
-> 
-> 2 forks & 2 execs for each user.
-> 
-> |
-> |Too many processes.  If you want progress reporting, say:
-> |
-> |while read user
-> |do
-> |	echo "Mailing $user"
-> |	mail $user <message
-> |done <user-list
-> |
-> 
-> 1 fork for the redirected while, 2 forks & 2 execs for each user.
-> 
-> Number of processes is the same (but you save an exec).
-> Alternative:
-> 
-> set -x     # Let the shell do the progress report.
-> for user in `cat user-list`; do mail $user <message; done
-> 
-> (1 fork & 1 exec for cat, 1 fork & 1 exec for each user).
-> 
-> Of course, for builtin echo's, not-forked redirected while loops the
-> situation differs.
-> 
->     Leo.

	And lets hope you don't work at an place where the password
file has a few thousand entries. This will start up a ridiculous number
of processes and bring the machine to its knees. 
	This was a torture test we used to do to machines to see how
they really performed.


Geoff Coleman



More information about the Comp.unix.questions mailing list