dru145 has asked for the wisdom of the Perl Monks concerning the following question:
#!/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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Need help with Parsing Unique Users out of Syslog
by dragonchild (Archbishop) on Sep 14, 2001 at 23:43 UTC | |
|
Re: Need help with Parsing Unique Users out of Syslog
by HamNRye (Monk) on Sep 15, 2001 at 00:51 UTC |