hi,
I would run SSH by thread,but with error message `SSHConnectionAborted`.
if I run it in main,it runs well.
Can anybody please help me in this?
use Net::SSH::Expect; use Expect; use thread; my $thr=threads->new(\&job,$console,$username,$password,$timeout); $thr->join(); sub job{ my ($console,$username,$password) = @_ my $consoleprompt = 'yes\/no|assword|[\$#>\]]$|[\$#>\]] $|>.$|].$'; my $ssh = Net::SSH::Expect->new( host => $console, user => $username, password => $password, timeout => $timeout, log_file => "./log/$console", raw_pty => 1 ); my $ssh->run_ssh() or die "SSH process coundn't start:$!"; $ssh->waitfor($consoleprompt,15); my $match=$ssh->match(); if($match =~ /yes\/no/) { print "known_hosts_tables not existing the device"; $ssh->send("yes"); $ssh->waitfor('assword',5); $ssh->send("$password"); } elsif($match =~ /assword/) { $ssh->send("$password"); } $ssh->waitfor($consoleprompt,5); $ssh->send("sup"); ... }
In reply to SSH by thread by hxbsy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |