the issue was very easily resolved when i discovered Parallel::ForkManager
following works wonderfully (excerpt):
...
...
my $pm = Parallel::ForkManager->new(10);
...
foreach $host (@allhosts) {
$pm->start($host) and next;
my ($MFSSH) = Net::OpenSSH->new($host,
port => $SSHPORT,
user => $USER,
password => $PASS,
default_stderr_fh => $stderr_fh,
default_stdout_fh => $stdout_fh,
master_opts => [-o =>
'StrictHostKeyChecking=no',
-o => 'ConnectTimeout 60'],
);
$EXITCODE = $MFSSH->error;
if ($EXITCODE eq "0") { #go to next host if ssh fails
foreach $CMD (@MFCMDS){
chomp($CMD);
( @CMDRESULT, $CMDERR ) = $MFSSH->capture($CMD);
print MFOH "\n$host COMMAND: $CMD\n";
foreach my $line (@CMDRESULT) {
print MFOH "$host $line";
}
@CMDRESULT = "";
if (defined $CMDERR ) {print MFOH "$host $CMDERR \n"; $CMDERR = "";}
}
}
undef $MFSSH;
$pm->finish;
}
...
...
no need to use ssh::parallel
________________________________
From: salvador fandino <[email protected]>
To: Rajeev Prasad <[email protected]>
Cc: "[email protected]" <[email protected]>
Sent: Monday, November 14, 2011 4:20 AM
Subject: Re: is this ssh happenign in parallel?
On Mon, Nov 14, 2011 at 12:43 AM, Rajeev Prasad <[email protected]> wrote:
> Salva,
>
> can you explain how to use variable expansion in your written module
> Net::Openssh and Net::Openssh::Parallel ? I want to be able to specify
> userid and password for the parallel ssh sessions using
> Net::Openssh::Parallel ...
There is no relation between the "variable expansion" feature and how
you specify the user and password for some host.
User and password can be used as follows:
$pssh->add_host($host, user => $user, password => $password);
- Salva
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/