#! /usr/bin/perl -w
use strict;
use 5.010;
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;
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