I was trying a code for executing commands on remote system using Net::SSH:Expect module. I have no problem in working with the code without multithreading. But when I appended threads with the existing code for better performance, it was giving errors.
Here is the code:
Error:#!/usr/bin/perl use Net::SSH::Expect; 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 { 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(); }
ssh: : Name or service not known
thread failed to start: SSHConnectionAborted at sshnew.pl line 30
please tell me any possible solution
Thanks in Advance.
In reply to Problem With Net::SSH::Expect using Multi threads by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |