Csh & foreach causing fork problems

Ralph Doncaster 880274d at aucs.AcadiaU.ca
Mon Mar 25 06:17:30 AEST 1991


I'm having problems with a script I made to mail all the students on our
system.   I often get a "fork: no more processes" error.
I assume this is because foreach starts a new process for each argument it is
given.
How can I solve this problem?
Here is the script:

#!/bin/csh
# bm (batch mailer) by Ralph Doncaster, Jan 25/91
# script to mail message to all accounts in /u/student
# usage: bm subject file
if ($#argv) then
	foreach i(`/bin/ls /u/student`)
		mail -s $1 $i < $2
		sleep 1
	end
	echo "Sending message file " $1 "to all accounts in /u/student."
else
	echo "Usage: bm subject file"
endif

-- 
+---------------------------------------------------------------------------+
|Ralph Doncaster        I don't have anything interesting to put in my .sig |
|880274d at AcadiaU.CA     330 CHI, Acadia U., Wolfville, NS B0P 1X0  542-3010 |
|UUCP: {uunet|watmath|utai}!cs.dal.ca!aucs!880274d  BITNET: 880274d at Acadia  |   +---------------------------------------------------------------------------+



More information about the Comp.unix.questions mailing list