Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Copying and Running PERL SCRIPTS in Parallel

by rahulruns (Beadle)
on May 21, 2013 at 07:08 UTC ( #1034464=perlquestion: print w/ replies, xml ) Need Help??
rahulruns has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to copy PERL SCRIPTS to hosts and then I need to run them in parallel. I am using Net::OpenSSH::Parallel to copy and run the commands. But I am not able to even copy the commands. It is a password less ssh. I am able to generate and store the host list in an array hosts.

my $pssh = Net::OpenSSH::Parallel->new(); $pssh->add_host($_) for @hosts; $pssh->push('*', scp_put => '/root/cpu.pl', '/root/'); $pssh->push('*', scp_put => '/root/memory.pl', '/root/');

Comment on Copying and Running PERL SCRIPTS in Parallel
Download Code
Re: Copying and Running PERL SCRIPTS in Parallel
by tobyink (Abbot) on May 21, 2013 at 07:11 UTC

    What error message do you get? Are you sure that @hosts contains the right data?

    use Data::Dumper; print Dumper(\@hosts);
    package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name

      There is no error message. The hosts has the right data. I use the code for other PERL SCRIPTS too

Re: Copying and Running PERL SCRIPTS in Parallel
by hdb (Prior) on May 21, 2013 at 07:26 UTC

    If I read the documentation for Net::OpenSSH::Parallel correctly, then all your copy commands will only be executed when one calls $pssh->run. This is missing from your code snippet.

Re: Copying and Running PERL SCRIPTS in Parallel
by salva (Abbot) on May 21, 2013 at 07:28 UTC
    You have to call the run method at the end, once you have declared all the actions that should be performed by the module:
    my $pssh = Net::OpenSSH::Parallel->new(); $pssh->add_host($_) for @hosts; $pssh->push('*', scp_put => '/root/cpu.pl', '/root/'); $pssh->push('*', scp_put => '/root/memory.pl', '/root/'); $pssh->run;

      Thank You All for pointing out the mistake (silly mistake). It is working now and I hope to resolve my issues

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1034464]
Approved by tobyink
Front-paged by derby
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (9)
As of 2015-01-25 17:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My top resolution in 2015 is:

















    Results (183 votes), past polls