Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I need to be able to extract the records which have "Login succeeded" but specifically only the user name from that record. e.g. sa, xyz, abc,qwr00:00000:00014:2005/11/30 10:01:23.77 server Configuration file '/opt +/sybase/SERVER1.cfg' has been written and the previous version has been renamed to '/opt/sybase/SERV +ER1.030'. 00:00000:00014:2005/11/30 10:01:23.80 server The configuration option + 'log audit logon success' has been ch anged by 'sa' from '0' to '1'. 00:00000:00015:2005/11/30 10:01:37.36 Logon Login succeeded. User: sa +, Client IP address: '169.123.26.124'. 00:00000:00016:2005/11/30 10:10:50.91 Logon Login succeeded. User: xy +z, Client IP address: '169.123.26.124'. 00:00000:00017:2005/11/30 16:31:31.02 Logon Login succeeded. User: sa +, Client IP address: '169.123.26.124'. 00:00000:00020:2005/11/30 16:51:11.90 Logon Login succeeded. User: sa +, Client IP address: '169.123.26.124'. 00:00000:00021:2005/12/01 09:49:23.44 Logon Login succeeded. User: ab +c, Client IP address: '169.123.26.124'. 00:00000:00022:2005/12/01 09:49:23.90 Logon Login succeeded. User: sa +, Client IP address: '169.123.26.124'. 00:00000:00023:2005/12/01 09:51:29.65 kernel Cannot read, host proces +s disconnected: SERVER1 spid: 23 00:00000:00025:2005/12/01 09:52:27.74 Logon Login succeeded. User: sa +, Client IP address: '169.123.26.124'. 00:00000:00026:2005/12/01 09:55:24.06 Logon Login succeeded. User: qw +r, Client IP address: '169.123.26.124'. 00:00000:00027:2005/12/01 09:55:47.15 Logon Login succeeded. User: sa +, Client IP address: '169.123.26.124'. 00:00000:00026:2005/12/01 10:02:25.95 server Configuration file '/opt +/sybase/SERVER1.cfg' has been written and the previous version has been renamed to '/opt/sybase/SERV +ER1.031'.
I actually just need one occurence of each different user that has successfully logged in. So in the above snippet sa has logged in several times but all I need to know is that they have logged in at least once
I started off by doing this
This just prints the whole line out. I was under the impression that the array is naturally split by a space ?use strict; my $line; my @array; # Open the errorlog file open(errlog,"/opt/sybase/logs/errorlog_SERVER1") or die "Can't open er +rorlog file!"; # Open th eoutput file open(loginf,">/tmp/login.dat"); while ($line = <errlog>) { chomp $line; next unless ($line =~ /Login succeeded/); push @array, $line; } foreach (@array) { print "$array[7]\n"; } close errlog; close loginf;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: array processing
by Tomte (Priest) on Dec 06, 2005 at 11:04 UTC | |
by inman (Curate) on Dec 06, 2005 at 11:34 UTC | |
Re: array processing
by holli (Abbot) on Dec 06, 2005 at 11:26 UTC | |
Re: array processing
by McDarren (Abbot) on Dec 06, 2005 at 11:51 UTC | |
Re: array processing
by tirwhan (Abbot) on Dec 06, 2005 at 11:07 UTC | |
by Anonymous Monk on Dec 06, 2005 at 11:19 UTC | |
by tirwhan (Abbot) on Dec 06, 2005 at 11:34 UTC | |
by inman (Curate) on Dec 06, 2005 at 11:47 UTC | |
by tirwhan (Abbot) on Dec 06, 2005 at 11:55 UTC | |
by Anonymous Monk on Dec 06, 2005 at 12:41 UTC | |
by tirwhan (Abbot) on Dec 06, 2005 at 12:58 UTC | |
by Anonymous Monk on Dec 06, 2005 at 13:12 UTC | |
by Anonymous Monk on Dec 06, 2005 at 13:31 UTC | |
Re: array processing
by McDarren (Abbot) on Dec 06, 2005 at 11:26 UTC |