我试图在下面的Perl代码中使用Net::SSH2,但是我得到了这个错误。
在test.pl第9行中,不建议在空上下文中调用connect。 Net::SSH2 2:未能连接到xx.xx.xxx.xx:ssh: test.pl第9行的坏文件描述符。
use strict;
use Net::SSH2;
#use Net::SSH2::Expect;
#my $Hostname = 'xx.xx.xx.xx';
my $ssh = Net::SSH2->new();
#$ssh->timeout(10);
$ssh->connect('xx.xx.xx.xx');有人能帮帮我吗?
发布于 2017-03-15 16:45:03
将connect方法保存在if或使用die_with_error中有助于我修复代码。
use strict;
use Net::SSH2;
my $ssh=Net::SSH2->new();
if($ssh->connect('xx.xx.xx.xx'))
{
print "successfully connected";
$ssh->auth_password('username','password') or $ssh->die_with_error;
}https://stackoverflow.com/questions/42795122
复制相似问题