Fellow monks, I am trying to capture output from a spawned child. But no luck, can someone help me? So I ended up processing everything at the child level. Below is a code snipet:
#!/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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.