perlknight has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -W use scr_rsh; my @properties = ("run","conf"); my $cmd_run = "ps -ef|grep match | grep \" 1 \"|wc -l"; my $cmd_conf = "wc -l /usr/local/match.conf"; my ($pid,@pid); my $passwd = ask; print "\n"; # hash of hashes our $domatch = {}; # Hash of Hashes # set default values of HoH for(my $key1 = 0; $key1 <= $#ARGV; $key1++) { foreach my $key2 (@properties) { my $domatch = { $ARGV[$key1 ] => {$key2=>'0'} }; } }# Fork processes for($key1=0, $i = 1; ($i <= 2) && ($key1 <= $#ARGV); $i++,$key1++) { $pid=fork(); push @pids, $pid; if($pid == 0) { #Child Process $domatch->{$ARGV[$key1]}->{"conf"} = &get_proc_run($passwd,$ARG +V[$key1]); #wanted to pass this result to parent $domatch->{$ARGV[$key1]}->{"run"} = &get_proc_conf($passwd,$ARG +V[$key1]); #wanted to pass this result to parent &prt_result($ARGV[$key1]); # wanted to execute this after all ch +ild are done exit(0); } if("$i" == "2") { $i=0; } } foreach my $childpid (@pids) { waitpid($childpid,0); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: parent wants to capture output from a spawned child
by chromatic (Archbishop) on Nov 24, 2001 at 11:17 UTC | |
|
Re: parent wants to capture output from a spawned child
by Zaxo (Archbishop) on Nov 24, 2001 at 12:02 UTC | |
by perlknight (Pilgrim) on Nov 26, 2001 at 01:04 UTC | |
by Zaxo (Archbishop) on Nov 26, 2001 at 02:02 UTC | |
|
Re: parent wants to capture output from a spawned child
by Dogma (Pilgrim) on Nov 24, 2001 at 16:02 UTC |