I'm writing a script for saving the switch configuration via save the output "show run" because in firmware has problems with working through tftp.
The output of "show run" is divided by 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>
Part of my script below:
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');
}
}
and the result of his work:
# 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>
How to fix it?