Perl Telnet 登录 Cisco交换机,并执行命令。
发布时间:2020-12-15 21:07:06 所属栏目:大数据 来源:网络整理
导读:#! /usr/bin/perl -w use strict; use 5.010; use Net::Telnet::Cisco; ? #需要安装这个module,需要有internet连接, windows安装命令如下 #c: cpan #cpan install?Net::Telnet::Cisco; ? #?hostip1?数组中可放入多个交换机地址,在循环中执行命令。 my @ho
#! /usr/bin/perl -w
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 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |