Gracious Monks
I'm in need of your assistance once again. I have the top part of the script matching on any username that has been added to the database and storing them in the @certs array, but I want the users who's certificate has NOT been either revoked or renewed. In the below DATA, psmith.512 and mchin.2048 are the only users who match this criteria. Also, I need to return the whole line, not just the username.
I think I'm close, but I've been working on this all night and all day and still is not coming to me.
Any ideas on how I can get this working?
Thanks - Dru
#!/usr/bin/perl -w
use strict;
my $calog = "/var/log/ca/ca.log.1";
my $line;
my @certs;
my $i;
my @newlist;
open LOG, "$calog" or die "Can't open $calog: $!\n";
while ($line = <DATA>){
if ($line =~ m/\'([\w.]+)\' added/) {
push(@certs, $1);
} #end if
for $i (@certs){
if ($line =~ m^/([\w.]+\.2048|512).+renewed|revoked/) {
push(@newlist, $1);
} #close if
} #close for
} #end while
print "@newlist";
__DATA__
Sep 14 14:00:04 nt-na-pk NA(Domain-ca): Certificate came 'tuser.512' a
+dded to database.
Sep 14 14:00:04 nt-na-pk NA(Domain-ca): tuser.512: This Certificate ha
+s been renewed.
Sep 14 14:02:02 nt-na-pk NA(Domain-ca): [mless] Certificate came 'muse
+r.2048' has been revoked.
Sep 14 14:02:31 nt-na-pk NA(Domain-ca): [mless] Certificate came 'muse
+r.2048' added to database.
Sep 14 14:08:49 nt-na-pk NA(Domain-ca): Certificate came 'muser.2048'
+added to database.
Sep 14 14:48:20 nt-na-pk NA(Domain-ca): Certificate came 'psmith.512'
+added to database.
Sep 14 14:48:20 nt-na-pk NA(Domain-ca): Certificate came 'mchin.2048'
+added to database.
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.