Hello everyone,
I'm attempting to parse the output of 'show access-list' over a period of days to determine if a line in the access-list does not receive a hit over a period of time. Please see my earlier post:
Parsing cisco log file
Below is the code I've come up with, I'm running into trouble with the last portion where I compare lines that have not received matches during day one to lines that haven't received matches on day two. I get nothing at all for output, any thoughts on where I have screwed up or how I can do this better would be much appreciated.
We're storing the output of sh access-list from a cisco #router in a file once a day for 30 days.
This script will eventually look at all 30 files and output the access-list entries that have not
recieved a match in all 30 files and therefore can be removed.
#/usr/bin/perl
#Prompt for the files we want to compare, for now just two
print "Enter filename that contains output of show access <list\n";
chomp ($aoutput = <STDIN>);
print "Enter the second file\n";
chomp ($aoutput1 = <STDIN>);
#Open our files
open (IN, $aoutput) || die "Couldn't open $aoutput $!";
open (LOG, ">>matches.txt") || die "Couldn't open matches.txt $!";
open (IN1, $aoutput1) || die "Couldn't open $aoutput1 $!";
#Push each line in file 1 that does not get any matches into an array
while (<IN>){
push @aoutput unless /matches\)$/;
}
#Push each line in file 2 that does not get any matches into an array
while (<IN1>){
push @aoutput1 unless /matches\)$/;
}
#See if the lines that didn't get matches on day 1
#didn't get matches on day 2 as well
#Gotta be a better way to do this?
while (<@aoutput>){
$linetemp = grep {/$_/i} @aoutput1;
if ($_ = $linetemp)
{
print $_;
}
}
edited: Fri Mar 14 23:17:01 2003
by jeffa - code tags
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.