Subject: psh
To: None <current-users@netbsd.org>
From: dustin sallings <dustin@spy.net>
List: current-users
Date: 10/18/1998 15:35:46
	Is anyone interested in this:

NAME
       psh - parallel command interpreter (shell)

SYNOPSIS
       psh [-/+aCefnuvxIimsVEb] [-/+o longname] [arg ...]

	I basically spent about ten minutes modifying the 1.3.2 bourne
shell to do this:

       The syntax of the pfor command is
           pfor variable in word...
           do   list
           done

       This appears to be the same as the for command above, but
       the work is done in parallel.  How many jobs are done in
       parallel depends on the value of the MAXKIDS environment
       variable.  The default value is one.  These loops are not
       guaranteed to be processed in order, but they will do all
       of the elements.

	I needed this really bad at work, because I run a cluster of
machines that all do exactly the same thing, so I've got a little shell
script that does a for loop to ssh to all the machines and run a command.
As I add machines, it takes longer and longer, and there's no reason to
run serially, so instead of doing:

for i in `cat machinelist`
do
	ssh $i $*
done

	I can do this:

MAXKIDS=8

pfor i in `cat machinelist`
do
	ssh $i $*
done

	And have it always be doing 8 at a time when it can.  The default
is 1, so it'll behave like an inefficient for loop (it'll still fork a
child to do the work.

	I haven't actually figured out how to read internal variables yet,
so I'm currently having to set the environment before I actually start the
program, but I'll probably think of a better way to do that anyway,
probably with a commandline argument and set.

	Anyway, this would be a really neat loop to have in a normal
bourne shell, but I'll get my use out of it anyway.

--
SA, beyond.com                            The world is watching America,
pub  1024/3CAE01D5 1994/11/03 Dustin Sallings <dustin@spy.net>
|    Key fingerprint =  87 02 57 08 02 D0 DA D6  C8 0F 3E 65 51 98 D8 BE 
L________________________________________ and America is watching TV. __