foreach $host (@hosts) { chomp ($host); my $templocal = "tmpclean.local.prl"; my $cmd_rsh ="/bin/rshto -to 60"; $pid = fork; if ($pid == 0) { # child print "$cmd_rsh $host $templocal 2 \n"; open(PIPEHANDLE, "$cmd_rsh $host $templocal 2 |"); my @output = ; close PIPEHANDLE; open(OUTFILE, ">> $output_file"); print OUTFILE @output; close OUTFILE; exit 1; } else { push(@pids,$pid); } if ($#pids > 10) { print "more than 10 processes running \n"; my $id = waitpid(-1,0); while (!(WIFEXITED($?)) ) {} $#pids = -1; #sleep 5; } }