I wrote a script that logs into a router and issues a 'show log' command. The entire show log is not captured and I believe it is do to a buffer issue. I have increased the max_buffer_length as high as possible - no luck. I manually set the bufmaxsize in Telnet.pm to over 8mb and still no luck. Anybody have some suggestions?

Thanks in Advanced!

Here is a scaled down snippet. The '@output = $session->cmd("show log");' is the command I need the full content of the routers show log. Yet the output array only extracts about 1/2 the log:

#!/usr/bin/perl

$username = "cisco";
$password = "cisco";
$enable_password = "cisco";
$zero_screen = "term len 0";

sub scan_log {
  my $cmd = "show log";
  my @output;
  my $previous;
 
  @output = $session->cmd("$cmd");
 
  foreach my $line (@output) {
    chomp($line);
    if ($line =~ /Trace/) {
      print "TRACEBACK MSG: $previous\n";
      print "TRACEBACK: $line\n";
    } else {
      $previous = $line;
    }
  }
}
 
sub node_login {
  my ($node_log) = @_;
  my $buffer_mb = 1024 * 1024;
 
  print "Logging into node: $node ...\n";
 
  # Login to node
  $session = Net::Telnet::Cisco->new(Host        => $node,
                                     Timeout     => $node_timeout,
                                     Prompt      => $prompt);
                                     #Dump_Log    => "dump.log",
                                     #Output_Log  => "commands_run.log",
                                     #Input_log   => $node_log);
 
  $session->send_wakeup;
  $session->login("$username", "$password");
  $session->enable($enable_password);
  $session->max_buffer_length(5 * $buffer_mb);
  $session->cmd($zero_screen);
}
 
$node = "router1"; 

node_login($node_log);
scan_log();

exit;

In reply to perl Telnet.pm and Cisco.pm input buffer by swoop

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.