
zohman
Novice
May 6, 2016, 12:31 AM
Post #4 of 4
(2262 views)
|
Re: [FishMonger] Capturing STDOUT from Parallel::ForkManager with SSH
[In reply to]
|
Can't Post
|
|
Thanks, yes, i tried to work with that with no success, but i figure it must be declared before first 'start' ($pm->start) and need to tale what we want to store in $pm->finish, so now it's working great and no need for tmpfile.
use Parallel::ForkManager; my $maxProbes = 100; # Max Processes my $pm = new Parallel::ForkManager($maxProbes); my @servers = ('host1.domain1.com','host2.domain2.com','host3.domain3.com','host4.domain4.com'); my %results; $pm->run_on_finish( sub { my ($pid, $exit_code, $ident, $exit_signal, $core_dump, $data) = @_; $results{ $data->[0] } = $data->[1]; }); foreach my $server (@servers) { $pm->start and next; my $stdout = qx { ssh $server domainname 2>&1 }; $pm->finish(0, [ $server, $stdout ]); } $pm->wait_all_children; Regards, Zohman.
|