D
Digger
#!/usr/bin/perl -w
#
$ARGV[0] = 'url2.log';
my %status;
while (<>) {
/ (FAILURE|SUCCESS).+?from (.+)/ and $status{$2} = $1;
}
print "URLs whose last status was SUCCESS:\n";
$status{$_} eq 'SUCCESS' and print " $_\n" for sort keys %status;
print "\nURLs whose last status was FAILED:\n";
$status{$_} eq 'FAILURE' and print " $_\n" for sort keys %status;
#
1) The above script prints out url's from a log file with the FAILED
status if and ONLY if further down the log file a SUCCESS is not
found. (so www.234.com ans www.abc.com would be echoed out)
IE:
snip from log file....
[2005-01-04 09:17:59] FAILURE RESPONSE www.123.com
[2005-01-04 09:18:59] SUCCESS RESPONSE www.678.com
[2005-01-04 09:19:59] FAILURE RESPONSE www.234.com
[2005-01-04 09:20:59] FAILURE RESPONSE www.abc.com
[2005-01-04 09:23:59] SUCCESS RESPONSE www.123.com
2) The above script prints out url's from a log file with the SUCCESS
status if and ONLY if further down it did not fail.
(so www.123.com www.123.com)
Anyway I would like to modify this program.
1. I would like instead of printing out the url's I would like it to
spit out a 1 if a FAILURE url is found and not cleared up further down
the file. So I am trying to add the following
print LOGFILE "1" if /FAIL/;
but it's not working..... If the log file has more than one FAILURE
it's printing out many 1's.
Thanks
~
#
$ARGV[0] = 'url2.log';
my %status;
while (<>) {
/ (FAILURE|SUCCESS).+?from (.+)/ and $status{$2} = $1;
}
print "URLs whose last status was SUCCESS:\n";
$status{$_} eq 'SUCCESS' and print " $_\n" for sort keys %status;
print "\nURLs whose last status was FAILED:\n";
$status{$_} eq 'FAILURE' and print " $_\n" for sort keys %status;
#
1) The above script prints out url's from a log file with the FAILED
status if and ONLY if further down the log file a SUCCESS is not
found. (so www.234.com ans www.abc.com would be echoed out)
IE:
snip from log file....
[2005-01-04 09:17:59] FAILURE RESPONSE www.123.com
[2005-01-04 09:18:59] SUCCESS RESPONSE www.678.com
[2005-01-04 09:19:59] FAILURE RESPONSE www.234.com
[2005-01-04 09:20:59] FAILURE RESPONSE www.abc.com
[2005-01-04 09:23:59] SUCCESS RESPONSE www.123.com
2) The above script prints out url's from a log file with the SUCCESS
status if and ONLY if further down it did not fail.
(so www.123.com www.123.com)
Anyway I would like to modify this program.
1. I would like instead of printing out the url's I would like it to
spit out a 1 if a FAILURE url is found and not cleared up further down
the file. So I am trying to add the following
print LOGFILE "1" if /FAIL/;
but it's not working..... If the log file has more than one FAILURE
it's printing out many 1's.
Thanks
~