Help Folks..
I have run into a small problem with the script we have been working on for
log management.
Problem 1 - The script must be in the same sub directory as all the logs.
How can I get the script to run from /var/tmp/gatelog and not in
var/tmp/gatelog/glogs
Problem 2 - The Line of the log dose not have the correct server name in
column one.
What I'm I doing wrong.
s00237 2002/12/31 20:47:34 +05 003503E0: STATUS DATA: jobqq= 0 jobqr= 0
reqdq= 0 gwmethods= 0
s00237 2002/12/31 21:47:37 +05 003503E0: STATUS DATA: jobqq= 0 jobqr= 0
reqdq= 0 gwmethods= 0
2002/12/31 22:47:45 +05 003503E0: STATUS DATA: jobqq= 0 jobqr= 0 reqdq= 0
gwmethods= 0
Below is the script we are using.
#!/usr/bin/perl -w
#chdir ("/var/tmp/gatelog/glogs") && die "cannot find directory";
my @Gatelogs_list = `ls`;
my $lineprint = '';
my $lines=`ls | wc -l`;
my $i=0;
my $line = '';
open (OUT, "> /var/tmp/gatelog/gatelog.txt");
while ($lines >$i){
open (IN,"$Gatelogs_list[$i]");
while (<IN>) {
chomp; # get rid of the newline
next if $_ eq ''; # skip empty lines
s/\s{2,}/ /g; # replace 2 or more whitespace chars
# with a single space
if ( m{^\d{4}/\d{2}/\d{2} \d\d:\d\d:\d\d} ) {
# if the current line starts with a
timestamp ...
# I assume the YYYY/MM/DD HH:MI:SS
format
chomp $Gatelogs_list[$i];
$lineprint = "$Gatelogs_list[$i]" . " "
. "$line";
print OUT $lineprint, "\n" if $line;
# print the buffer
$line = $_;
# remember the current line
} else {
$line .= '' . $_;
# add the current line to
the buffer
}
}
close IN;
$i++;
}
print OUT $line, "\n" if $line;
# print the last buffer
close OUT;
exit 0;
Thanks for help in this matter�
Tim