Welcome to the Monastery | |
PerlMonks |
Re: Do I need threads?by TechFly (Scribe) |
on Dec 21, 2011 at 21:37 UTC ( [id://944700]=note: print w/replies, xml ) | Need Help?? |
Thank you all. From the advice I got here, I looked closer at fork(), and found it is a perfect fit for what I want. I did some test scripts, and found that I can fork() and wait for the return while using the children to all print their output to a common (opened before the fork) file with the first line the PID of the process. Then I can sort it to get the output from each and check for errors. This approach has proven to be simple (complicated until I got a little more familiar) and very effective. The result is that I can run all of them at once and wait for the response. In case anyone wanted to see, this is the test script. The file that it opens contains a list of servers to hit, and the script just echos the host name followed by a 30 second wait both executed on the remote host.
It is not super clean (it will implode on itself if the fork fails), but it is functional, and will get cleaned up as I work on the full 'real' script. Thanks again for the help guys.
In Section
Seekers of Perl Wisdom
|
|