develooper Front page | perl.beginners | Postings from September 2011

Re: how to use Net::OpenSSH::Parallel

Thread Previous | Thread Next
From:
Rajeev Prasad
Date:
September 17, 2011 09:15
Subject:
Re: how to use Net::OpenSSH::Parallel
Message ID:
1316276110.73959.YahooMailNeo@web114212.mail.gq1.yahoo.com
On Sep 14, 11:57 pm, rp.ne...@yahoo.com (Rajeev Prasad) wrote:
> trying to use this module now. but i guess i have a very basic issue:
>
> currently i am running following in a loop for all hosts (and a inner loop for all commands for a host):
>
>     my ($MFSSH) = Net::OpenSSH->new($HOST,
>                             user => $USER,
>                             password => $PASS,
>                             default_stderr_fh => $stderr_fh,
>                             default_stdout_fh => $stdout_fh,
>                             master_opts => [-o => 'StrictHostKeyChecking=no',
>                                                  -o => 'ConnectTimeout 10'],
>                             );
>     $EXITCODE = $MFSSH->error;
>     next if ($EXITCODE ne "0");            #go to next host if ssh fails
>     foreach $CMD (@MFCMDS){
>     chomp($CMD);
>     ( @CMDRESULT, $CMDERR ) = $MFSSH->capture("$CMD");
>     }
>
> how can i use Net::OpenSSH::Parallel this script? i mean i understood creating a new instance like pssh in the module CPAN page, but not sure how to integrate it with the script i already have.

Net::OpenSSH::Parallel does not allow capturing directly the output of
commands into perl scalars. You have to redirect it to some file and
then reread it.

It would be easier to help you if you tells us what you need to do
from a higher level.

------------------------------------
 
Hi Salva,
Thx for responding. I need to SSH into several nodes and run some commands there and capture the modified output to a file on local node from where the script is run.
 
-rgds,
Rajeev

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About