#!/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); }
In reply to parent wants to capture output from a spawned child by perlknight
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |