CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Advanced: and not populating array with full contents


New User

Oct 30, 2009, 6:31 AM

Post #1 of 1 (2294 views) and 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 and was not taking. So I then modified 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 or and some sort of buffering issue. Can someone lend a tip? Below is a snippet of the script:


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) {
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->login("$username", "$password");
$session->max_buffer_length(5 * $buffer_mb);

$node = "router1";


(This post was edited by swoop on Oct 30, 2009, 6:52 AM)


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives