Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
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/');

Replies are listed 'Best First'.
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

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 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

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?
[james28909]: i forgot how to link my scratch pad
[Lady_Aleena]: [pad://]
[james28909]: my scratchpad
[james28909]: and like i say, is just an example, not working code, but hopefully you understand what i mean. :)
[james28909]: and like i say, it would be alot of work to get around renaming 3 subs haha
[Lady_Aleena]: Well, you would have to add the file munging and a lot more.
[james28909]: yeah but it would rename those subs xD
[Lady_Aleena]: I'd say, go back to my scratchpad, and really look at what the 3 subs are doing, then play. Meanwhile, I am going afk for about an hour +/- a few minutes.

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2017-05-24 05:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?