in reply to Running PERL SCRIPTS in Parallel
# untested! require POSIX; sub ssh_run_parallel { my ($label, $ssh, @cmds) = @_; my @pids = map $ssh->spawn(@$_), @cmds; my $error = 0; for (@pids) { waitpid $_, 0; $error ||= $?; } POSIX::_exit($error); } my $pssh = Net::OpenSSH::Parallel->new(); $pssh->add_host($_) for @hosts; $pssh->push('*', scp_put => '/root/cpu.pl', '/root/memory.pl', '/root/ +'); $pssh->push('*', parsub => \&ssh_run_parallel, ['/usr/bin/perl', '/root/cpu.pl', '/tmp/cpu'], ['/usr/bin/perl', '/root/memory.pl', '/tmp/memory']); $pssh->run;
update: the error pointed by rahulruns below has been fixed!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Running PERL SCRIPTS in Parallel
by rahulruns (Scribe) on May 22, 2013 at 08:15 UTC | |
by salva (Canon) on May 22, 2013 at 08:23 UTC | |
by rahulruns (Scribe) on May 22, 2013 at 08:22 UTC |