Unknown User wrote:
Hi

Hello,

I wrote the following script to fork ssh processes with perl and
Parallel::ForkManager:

#!/usr/local/bin/perl -w
use strict;

my @cmd = "@ARGV";

Why would you use an array to store a single scalar value?

Either:

my $cmd = "@ARGV";

Or:

my @cmd = @ARGV;


use Parallel::ForkManager;
my @nodes;
open(NODE,"<list") || die "!$\n";
while(<NODE>) {
        chomp;
        push(@nodes,$_);
}

No need for the while loop:

chomp( my @nodes = <NODE> );


my   $pm = new Parallel::ForkManager(10);       # Max 10 procs
for my $node(@nodes) {
        my $pid = $pm->start and next;
        my $res = `ssh $node "@cmd"`;
        print "$res";

perldoc -q quoting

        $pm->finish;
        
}



John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction.                   -- Albert Einstein

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to