펌웨어에 tftp 작업에 문제가있어 "show run"출력을 통해 스위치 구성을 저장하는 스크립트를 작성하고 있습니다. "show run"의 출력은 게시물 More: <space>, Quit: q, One line: <return>
으로 나뉩니다.perl telnet - 여러 페이지의 출력을 처리하는 방법
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>
부
# 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>
어떻게 그것을 해결하기 위해?
문제 해결 –