我正在编写一个脚本,通过保存输出"show run“来保存交换机配置,因为在固件中通过tftp工作有问题。"show run“的输出除以posts More: <space>, Quit: q, One line: <return>。
# sh run
no spanning-tree
interface port-channel 1
shutdown
exit
interface port-channel 2
shutdown
exit
interface port-channel 3
shutdown
exit
interface port-channel 4
shutdown
exit
interface port-channel 5
shutdown
exit
interface port-channel 6
shutdown
exit
interface port-channel 7
shutdown
exit
More: <space>, Quit: q, One line: <return>下面是我的脚本的一部分:
foreach (@linksys_sps){
print ("Connecting to ",$_,"\n");
my $telnet = new Net::Telnet ( Timeout=>10,Errmode=>'return');
$telnet->open($_);
if ($telnet->errmsg){
print "Can't connect to " . $_ . " Error: " . $telnet->errmsg . "\n";
} else {
$telnet->waitfor('/User Name:$/i');
$telnet->print('admin');
$telnet->waitfor('/Password:$/i');
$telnet->print('password');
my @lines = $telnet->cmd("sh run");
print @lines;
sleep(5);
$telnet->print('exit');
}
}以及他的工作成果:
# sh run
no spanning-tree
interface port-channel 1
shutdown
exit
interface port-channel 2
shutdown
exit
interface port-channel 3
shutdown
exit
interface port-channel 4
shutdown
exit
interface port-channel 5
shutdown
exit
interface port-channel 6
shutdown
exit
interface port-channel 7
shutdown
exit
More: <space>, Quit: q, One line: <return>如何修复它?
发布于 2013-03-04 07:15:53
您的交换机上是否有将页面长度设置为零(0)的选项?如果是这样的话,你必须在执行'sh run‘命令之前添加它。
发布于 2013-07-13 23:14:42
在alcatel 6224和Dell powerconnect 3548上工作正常:
my @lines = $telnet->cmd("terminal datadump");
@lines = $telnet->cmd("show run");https://stackoverflow.com/questions/15191635
复制相似问题