我正在编写一个使用的程序Net::Telnet
,但是当我尝试$tel->cmd
在第 41 行使用时,出现错误。
CoyoteBridge4000.pl 第 41 行命令超时
该命令有效,但输出很大,这就是我认为发生超时的原因。我能做些什么来解决这个问题?由于我尝试更改超时并没有解决问题。
#!/usr/bin/perl
use Net::Telnet ();
$tel = new Net::Telnet();
print "\nFile Name\n\n";
my $name = <>;
chomp $name;
my @equipament;
my $i = 0;
my $username = "admin";
my $passwd = "zhone";
my $certo = 0;
$co = "bridge show vlan 4000";
open(arquivo, "ip.txt");
my $i = 0;
while (<arquivo>) {
$equipament[$i] = $_;
chomp $equipament[$i];
$i++;
}
close(arquivo);
open(resp, ">$name.csv");
foreach (@equipament) {
eval { $tel->open($_); };
if ($@) {
chomp $_;
print resp "$_, UNREACHABLE\n";
}
else {
open(re, ">temp.txt");
$tel->login($username, $passwd);
###ERROR###
@lines = $tel->cmd(String => "$co", Timeout => 600);
#####ERROR#####
print re @lines;
close(re);
open(re, "temp.txt");
$encontrar = ":";
while (<re>) {
if ($_ =~ /$encontrar/) {
chomp $_;
print resp $_;
}
}
close(re);
}
}
close(resp);
print "\n\n DONE \n\n";