
swoop
New User
Oct 30, 2009, 6:31 AM
Post #1 of 1
(2123 views)
|
Telnet.pm and Cisco.pm not populating array with full contents
|
Can't Post
|
|
I wrote a script that logs into a Cisco router then issues the 'show log' command. The log is very large. So I tried to set the max_buffer_length which Cisco.pm and Telnet.pm was not taking. So I then modified Telnet.pm maxbufsize with 8mb. Still the entire 'show log' contents are not extracted completely. The @output array only extracts about halft the log. Enabling the Dump_log and Input_log does not show details what the problem is. I believe it is a problem with either Telnet.pm or Cisco.pm and some sort of buffering issue. Can someone lend a tip? Below is a snippet of the script: #!/usr/bin/perl use Net::Telnet::Cisco; $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;
(This post was edited by swoop on Oct 30, 2009, 6:52 AM)
|