swoop has asked for the wisdom of the Perl Monks concerning the following question:
#!/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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: perl Telnet.pm and Cisco.pm input buffer
by NetWallah (Canon) on Oct 30, 2009 at 03:56 UTC | |
by swoop (Acolyte) on Oct 30, 2009 at 05:27 UTC | |
|
Re: perl Telnet.pm and Cisco.pm input buffer
by affc (Scribe) on Oct 29, 2009 at 23:51 UTC |