Я новичок в Windows Perl и пытаюсь использовать Net :: SSH2 на Strawberry Perl .проблема у меня скрипт не может подключиться к списку устройств.Я могу подключиться к первому устройству в списке, но не могу подключиться ко второму, третьему и т. Д.я что-то пропустил.спасибо за любое предложение.
#!\usr\bin\Perl\bin\perl
use warnings;
use strict;
use NET::SSH2;
use MIME::Base64;
my $host = "C:/temp/devices.txt"; # input file
my $user = "XXX"; # your account
my $pass = "XXXXX"; # your password 64 bit mime
my $ssh2 = Net::SSH2->new();
my $result = "C:/temp/result.txt"; # output file
$ssh2->debug(1); # debug on/off
open(List, '<', "$host") or die "$!";
while(<List>) {
chomp $_;
unless ($ssh2->connect("$_")) {
print "Unable to connect : $_\n";
next;
}
my $dp=decode_base64("$pass");
unless ($ssh2->auth_password("$user","$dp")) {
print "Invalid Password\n";
exit;
}
my $chan = $ssh2->channel();
$chan->exec('sh ver');
my $buflen =100000;
my $buf = '0' x $buflen;
my $read = $chan->read($buf, $buflen );
warn 'More than ', $buflen, ' characters in listing' if $read >= $buflen;
open (OUTPUT, '>>', $result) or die "$!";
print OUTPUT "HOST: $_\n\n";
print OUTPUT "$buf\n";
print OUTPUT "\n\n\n";
print OUTPUT
$chan->close();
}
close (List);