我已经下载了运行下面提到的 perl 脚本所需的所有模块:
use Net::SSH::Perl;
my $host = "172.16.170.116";
my $user = "HGamit";
my $password = "";
#-- set up a new connection
my $ssh = Net::SSH::Perl->new($host);
#-- authenticate
$ssh->login($user, $pass);
#-- execute the command
my($stdout, $stderr, $exit) = $ssh->cmd("perl C:/Monitor/ltp.pl C:/monitor");
但是报错:Can't connect to 172.16.170.116, port 22: No connection could be made because the target machine主动拒绝。在 C:/Perl/site/lib/Net/SSH/Perl.pm 第 206 行。然后我尝试了 telnet,但它不工作。
use warnings;
use Net::Telnet;
$telnet = new Net::Telnet ( Timeout=>2, Errmode=>'die');
$telnet->open('172.16.170.116');
$telnet->waitfor('/HGamit\s*/');
$telnet->print('admin');
$telnet->waitfor('/\s*/');
$telnet->print('Blue');
#$telnet->cmd('ver > C:\\log.txt');
$telnet->cmd('perl C:/Monitor/ltp.pl C:/monitor');
谁能提供一些解决方案来解决这个问题?