- 论坛徽章:
- 0
|
不知道这样是不是符合你的要求
#!/usr/bin/perl
use strict;
use warnings;
my $conf_file = '/etc/awstats/awstats.test.conf';
open CONF, "<$conf_file"
or die "Can not open $conf_file: $!\n";
my @time = localtime;
my $day = $time[3] + 1;
my $mon = $time[4] + 1;
my $year = $time[5] + 1900;
while (<CONF>) {
chomp;
my $awsday = $1 if /^LogFile\D*\d{6}(\d+)/;
if ($day >= $awsday) {
my $log_file1 = sprintf "%s%d%02d%02d%s", "/var/log/http1", $year, $mon, $awsday, "-access.log";
my $log_file2 = sprintf "%s%d%02d%02d%s", "/var/log/http2", $year, $mon, $awsday, "-access.log";
my $httplog = sprintf "%s%d%02d%02d", "/var/log/http_log", $year, $mon, $awsday;
open LOG1, "<$log_file1"
or die "Can not open $log_file1: $!\n";
open LOG2, "<$log_file2"
or die "Can not open $log_file2: $!\n";
open HTTP_LOG, ">>$httplog"
or die "Can not open $httplog: $!\n";
while (<LOG1>) {
chomp;
next if /1.2.3.4 4.3.2.1/;
next if /4.3.2.1 1.2.3.4/;
print HTTP_LOG;
}
while (<LOG2>) {
chomp
next if /1.2.3.4 4.3.2.1/;
next if /4.3.2.1 1.2.3.4/;
print HTTP_LOG;
}
}
}
|
[ 本帖最后由 cobrawgl 于 2008-5-6 20:16 编辑 ] |
|