hi shawn/omega/salva, i think there is some communication gap. so to address my issue differently. can you guys plz. paste an example of code where you are usign this parallel module to ssh into many systems and, run some commands there (say you can use ls -l for your example) and change that output a bit then, store the output in a file. i think that example will speak a thousand words and will take care of shortcomings in communication. i did seacrh the net for examples on this module: i found none. thx.
From: shawn wilson <ag4ve...@gmail.com> To: Cc: "beginners@perl.org" <beginners@perl.org> Sent: Saturday, September 17, 2011 12:21 PM Subject: Re: how to use Net::OpenSSH::Parallel On Sep 17, 2011 12:16 PM, "Rajeev Prasad" <rp.ne...@yahoo.com> wrote: > > 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. > That's not saying what you want to do. That's saying what you think the script should do in order to achieve a goal. Now, I've never used that module but there's probably an anyevent module for doing what you want. It might also be possible to use ipc::run objects which might get you clover to what you want.