use strict;
use 5.010;
use Net::Telnet::Cisco;
#需要安裝這個module, 需要有internet連接, windows安裝命令如下
#c:\> cpan
#cpan> install Net::Telnet::Cisco;
# hostip1 數組中可放入多個交換機地址,在循環中執行命令。
22.10.100.11
);
foreach my $ip (@hostip1) {
my $conn = Net::Telnet::Cisco->new(Host => $ip);
my $vtyPass = 'xxxxxxxx'';
my $enaPass = 'xxxxxxxx';
$conn->login(Password => $vtyPass);
$conn->enable($enaPass);
my $cmd = 'show run';
@output = $conn->cmd($cmd);
print "Output: @output";
$conn->close;
}
# 參考網址 http://www.litvip.com/2011/08/29/554