in reply to Problem With Net::SSH::Expect using Multi threads
#!/usr/bin/perl use threads; @hosts = ('192.168.1.222',192.168.1.169); my $machine; foreach $machine ( @hosts ) { push @threads, threads->create(\&sshd,$machine); } while ( my $thread = shift @threads ) { $thread->join ; print " Thread [ $machine ] Ending ... \n"; } sub sshd { require Net::SSH::Expect; my $ssh = Net::SSH::Expect->new(host=>'$ip', user=>'root',pass +word=>'access') or die "cannot open"; $login_check=$ssh->login(); print "LOGIN for $ip -- $login_check \n"; my $who = $ssh->exec('hostname'); my $ls = $ssh->exec('ls -l |grep Desktop'); print "$who \n"; print "$ls \n"; $ssh->close(); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Problem With Net::SSH::Expect using Multi threads
by Anonymous Monk on Aug 20, 2007 at 13:25 UTC |