routedude has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Parsing cisco router command output (potential answer, untested)
by ybiC (Prior) on Mar 14, 2003 at 20:03 UTC | |
|
Re: Parsing cisco router command output
by Enlil (Parson) on Mar 14, 2003 at 20:31 UTC | |
|
Re: Parsing cisco router command output
by Vorlin (Beadle) on Mar 14, 2003 at 22:05 UTC |