ファームウェアではtftpでの作業に問題があるため、出力「showrun」を保存してスイッチ構成を保存するためのスクリプトを作成しています。「showrun」の出力は投稿で分割され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>
それを修正する方法は?