2013-03-03 2 views
0

펌웨어에 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> 

어떻게 그것을 해결하기 위해?

답변

1

페이지 길이를 0으로 설정하는 옵션이 스위치에 있습니까? 그렇다면 'sh run'명령을 수행하기 전에 추가해야합니다.

+0

문제 해결 –

0

ALCATEL 6224과 같은 델의 Powerconnect 3548에 그것은 작동합니다

my @lines = $telnet->cmd("terminal datadump"); 
@lines = $telnet->cmd("show run");