walkingthecow has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use strict; use FindBin qw ($Bin); use lib "$Bin/lib"; use ForkManager; use General; use Benchmark; getPassword("Please enter your password: "); my $start = new Benchmark; open SERVERS,"$ARGV[0]" or die $!; my (@hosts)=<SERVERS>; close SERVERS; my $sshscript = "checkUname.pl"; my $maxProbes = 20; # set this to one to do one at a time my $pm = new ForkManager($maxProbes); foreach my $hostname (@hosts) { $pm->start and next; my $stdout = `./$sshscript $hostname`; print "$stdout\n"; $pm->finish; } $pm->wait_all_children; print "done\n"; my $end = new Benchmark; my $diff = timediff($end, $start); print "Time taken was ", timestr($diff, 'all'), " seconds";
#!/usr/bin/perl use strict; use FindBin qw ($Bin); use lib "$Bin/lib"; use General; use Functions; my $host=$ARGV[0]; $General::password=$ENV{'PASSWORD'}; my $login = getPrompt($host); die "Could not connect to $host" if $login ne "SUCCESSFUL!"; my $result = getOSType(); print $result;
#!/usr/bin/perl use strict; use FindBin qw ($Bin); use lib "$Bin/lib"; use ForkManager; use General; use Benchmark; getPassword("Please enter your password: "); my $start = new Benchmark; open SERVERS,"$ARGV[0]" or die $!; my (@hosts)=<SERVERS>; close SERVERS; my $sshscript = "checkUname.pl"; my $maxProbes = 20; # set this to one to do one at a time my $pm = new ForkManager($maxProbes); foreach my $hostname (@hosts) { $pm->start and next; #my $stdout = `./$sshscript $hostname`; my $login = getPrompt($hostname); next if $login ne "SUCCESSFUL!"; my $stdout = getOSType(); print "$stdout\n"; $pm->finish; } $pm->wait_all_children; print "done\n"; my $end = new Benchmark; my $diff = timediff($end, $start); print "Time taken was ", timestr($diff, 'all'), " seconds";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Simultaneous SSH sessions with Parallel::ForkManager + Expect
by 5mi11er (Deacon) on Mar 26, 2009 at 21:59 UTC | |
|
Re: Simultaneous SSH sessions with Parallel::ForkManager + Expect
by ladyphnx (Novice) on Mar 27, 2009 at 14:24 UTC |