Perl log parcer. (for custom logs details inside)

OS:sol8

ok 2 things are very important. I will give examples of the logs and the client file for testing.

Object: to display on the web sometime to parse your custom logs basied on the inputed date and client selected.

I know alot of ppl are like who care. but i saw a perl script on here that gave me an idea on how do to this. so thanks auswipe for the logic. this is how i was able to turn something i saw into something i can use.

CLIENT LIST

[hostname]optimus_P$cat /var/adm/scripts/client_list
A000
A111
A222
#A333
A444

LOG FILE
logname = 20020830.ncftp_in.log

CLIENT: A111     TIME: 20:25:00
file1
file2

CLIENT: A222     TIME: 20:25:00
file1

CLIENT: A111     TIME: 20:30:00
file3
file4
file5

CLIENT: A333     TIME: 20:30:01
file1
file2

CLIENT: A444     TIME: 20:35:00
file1
file2

CLIENT: A111     TIME: 20:35:00

The script:

#!/usr/bin/perl -w

use CGI qw(:standard);

$PTITLE="Inbound and Outbound Log Checker";

print header, start_html($PTITLE), h2($PTITLE), hr;

$CLIENTFILE="/var/adm/scripts/client_list";

open(CLIENTFILE, "$CLIENTFILE") || bail ("$CLIENTFILE: \($!\)");
foreach (<CLIENTFILE>) {
        chomp;
        push(@client_list,$_) if ( $_ =~ /^\w/);
};


print start_form();
        print ("What client do you want to see? ",popup_menu("client_code", \@client_list)) ;
        print br(sup("note: DMZ files are NOT SHOWEN on the INBOUND side"));
        print p("Inbound or Outbound log? ",radio_group("in_out", ["in","out"]));
        print ("Enter a logdate",textfield(
                -NAME => "date",
                -DEFAULT => `date +%Y%m%d`,
                -OVERRIDE => 0,
                -SIZE => 7));
        print br(sup("ex. 20020131 = year 2002/month 01/day 31"));
        print p(submit("search"), reset("clear"));
print end_form(),hr();

if (param()) {
        print (h2("Current Time: ", `date`, hr));
        $date=param("date");
        $in_out=param("in_out");
        $LOGFILE="/homes/log/${date}.ncftp_${ in_out }.log";
        open(LOGFILE, "$LOGFILE") || bail ("$LOGFILE: \($!\)");
        foreach (<LOGFILE>) {
                chomp;
                push(@lines,$_);
        };

        $client=param("client_code");
        for ($i = 0; $i <= $#lines; $i++) {

                if (($lines[$i] =~ m/CLIENT\: $client/i) && ($lines[$i+1] =~ /\S/)) {
                        print br;

                        while ($lines[$i] =~ /\S/) {
                                print ("$lines[$i]");
                                print br;
                                $i++;
                        };
                };
        };
};

print end_html;

sub bail {
        $error="@_";
        print h1("Unexpected Error"), p($error), end_html;
        die $error;
}

:smiley: Glad that my code could have been of some assistance. :smiley:

That Perl is purt near good for ripping apart log files, eh?