Domanda

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?

È stato utile?

Soluzione

Is there an option on your switch to set page length to zero (0)? If so you'd have to add that before performing the 'sh run' command.

Altri suggerimenti

On alcatel 6224 and same Dell powerconnect 3548 it works:

my @lines = $telnet->cmd("terminal datadump");
@lines = $telnet->cmd("show run");
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top