in reply to Working in parallel
Something like this?
#! perl -slw use strict; use threads; use threads::shared; use Net::Telnet; my %data :shared; sub thread { my( $machine, $user, $pass, $cmd ) = @_; $t = new Net::Telnet ( Timeout => 10, Prompt => '>' ); $t->open( $machine ); $t->login( $user, $pass ); my @lines :shared = $t->cmd( $cmd ); $t->close; lock %data; $data{ $machine } = \@lines; return; } # AoA each sub array containing machineId, username, password and comm +and to run my @credentials = ...; my @threads = map threads->create( \&thread, @$_ ), @credentials; $_->join for @threads; ## Do something useful with the data gathered in %data.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Working in parallel
by locked_user sundialsvc4 (Abbot) on Aug 20, 2010 at 19:34 UTC | |
by BrowserUk (Patriarch) on Aug 21, 2010 at 01:03 UTC | |
by locked_user sundialsvc4 (Abbot) on Aug 25, 2010 at 03:46 UTC | |
|
Re^2: Working in parallel
by Anonymous Monk on Aug 20, 2010 at 11:40 UTC | |
by BrowserUk (Patriarch) on Aug 20, 2010 at 11:52 UTC |