in reply to Forking Problem

Instead of forking directly, I would do a pipe open (with -| or |-). Then in the children, I'd exec the ssh command. Now you should be able to read from the pipes in the parent process (I would use a select loop, but there are also modules to help you if you find the select loop idiom awkward).

I don't have time today to write an example. If you aren't able to solve your problem by tomorrow, I try to remember to revisit this note and write an example.

Replies are listed 'Best First'.
Re^2: Forking Problem
by smithgw (Initiate) on Aug 28, 2008 at 16:02 UTC
    Thanks for the insight. However, I am a little stumped with your answer. Would all the children be pushing to the same pipe? (I was trying to keep everything seperate, ie seperate log file for each ssh I kick off). Thanks
      No, each time you do
      my $pid = open(my $child, "-|") // die "Fork failed: $!";
      you fork, and get a different pipe (there will be a pipe for each child).

      You might want to look in the "Safe Pipe Opens" section of the perlipc manual page for example code, and a description on how to open a pipe between a parent and a child.