[Israel.pm] fork and rsh top

Tal Kelrich tal at musicgenome.com
Thu Jul 15 08:24:02 PDT 2004

On Thu, 15 Jul 2004 15:53:43 +0300
Offer Kaye <offer.kaye at gmail.com> wrote:

> Question 1 - can this be made parallel in tcsh? bash?

this seems to work, quick and dirty

stations="foo bar baz"
for station in $stations ; do
	(rsh $station "top n1 b | head -14 | tail -4") \
		2>/dev/null > ${tmpbase}_${station} &

#collect them all!

#now output
for station in $stations ; do
	echo $station:
	cat ${tmpbase}_${station}
	rm ${tmpbase}_${station}

> Question 2: The order of the reported stations was random. I guess I
> should have expected this (due to the nature of fork), but is there a
> way to get the outputs in the same order as the list of hosts?

You'd probably want to use pipes here, then read them at your leisure


Tal Kelrich
PGP fingerprint: 3EDF FCC5 60BB 4729 AB2F  CAE6 FEC1 9AAC 12B9 AA69
Key Available at: http://www.hasturkun.com/pub.txt
There is nothing wrong with writing ... as long as it is done in private
and you wash your hands afterward.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://perl.org.il/pipermail/perl/attachments/20040715/7f4c35e2/attachment.pgp 

More information about the Perl mailing list