On Jul 7, 11:53 am, [EMAIL PROTECTED] (Rob Dixon) wrote:
> Andy wrote:
>
> > Funny how when you talk to different people you get different ways of
> > looking at it.
>
> > One of the Perl guys at my office. told me that I can use
> > use strict;
> > use warnings;
>
> > but he said , he really doesn't because he wants the script to do what
> > it needs to do...
>
> Then he is a fool and should be disregarded. Perhaps he could post to this 
> group
> to explain himself?
>
> > I have made corrections as you suggested.
> >  I have included.
>
> > use strict;
> > use warnings;
>
> > as well as
> >  my $TIME  =$fields[3]
>
> > However after that ,
> > I still get zero output.
>
> > Maybe I have this written .....
>
> Have you incorporated all the corrections that John posted in his first
> response? Perhaps you should post your program in its current state so that we
> can take another look.
>
> Rob

Thank you all for the patience.

I have been doing some debugging...well as much of it as I can handle
with no exp...

This is the current code. I figured out with some help that My
$Dateroot was trying to read
incoming.xferlog.xferlog.csv.....

Eventually I want to run "perl andylog.pl and it will Parse all the
xferlogs in the dir.

Thus far with all your help I have it working...now for the tweaks.

I have some lines longer than the other and I have to figure out how
to skip those lines ...

So now I have to figure out how to read them all even longer ones
Tue Apr 29 00:02:13 2008 0 x.x.x.x 521 /home3/FTP-protected/TFN/ixx/
GPSdetail_rpt_20080428_200525.txt b _ i r xxx ftp 0 * c
Tue Apr 29 00:03:40 2008 25x.x.x.x 4246252 /home4/FTP-protected/
DATAWORKS/1234/user_nameEUestimates_2000.zip b _ o r username ftp 0 *
c


use strict;
use warnings;
        #Define LogFiles
my $dateroot=$ARGV[0]; # Value should be 2-digit month
my $outgoing="outgoing_xferlog.$dateroot.csv";  # This is for all
files sent to users
my $incoming="incoming_xferlog.$dateroot.csv";  #This is log for
uploads
my $loginsinlog="loginsinlog_xferlog.$dateroot.csv";   # This is where
log users
my $completedlog="completedlog_xferlog.$dateroot.csv";  # All
Completed Sessions
my $failedlog="failedlog_xferlog.$dateroot.csv";       # This is for
all Failures
my %loginsin;
my %completed;
my %failures;
my %incoming;
my %outgoing;

             #Time Measured
print "Started Processing Logfiles for $dateroot at " .
(localtime) ."\n\n";
             #Open Log File Dir to Read .log file(s)
opendir (DIR, ".") or die "$!";

#my @logfiles = grep {/xferlog\.$dateroot/,}  readdir DIR;
my @logfiles = grep {/$dateroot/,} readdir DIR;
close DIR;

           #Start Log Processing
foreach my $logfile (@logfiles) {
   print "Started Processing: $logfile at " . (localtime) ."\n";
   open(FH,"./$logfile") or die "$!";
   while ( my $lines = <FH> ) {
     chomp($lines);
      my @fields = split / /, $lines; #This is where we look for the .
extensions from the file name
#       next if /^#/;
#        next if /^(\s)*$/;
              #My Ftp Status Log Values
      my $TIME  =$fields[3]||'NULL';#fields[1],fields[2],fields[3];
      my $YEAR = $fields[4]||'NULL';
      my $IP = $fields[6]||'NULL';
      my $SIZE = $fields[7]||'NULL';    #filesize
      my $FILE = $fields[8]||'NULL';    #filename and path
      my $DIRECTION = $fields[11]||'NULL'; #Outgoing, Incoming
      my $USERNAME = $fields[13]||'NULL';
      my $STATUS= $fields[17]||'NULL';   #c = completed  i=incomplete
    ( my $MASKFILE = $FILE ) =~ tr/0-9/#/; #$cnt = tr/0-9//;# count
the digits in $_

                          #Failures    This is where we check for
failures
if ($DIRECTION eq "i" and $STATUS ne "c" ){$failures {$USERNAME}   =
$TIME.",".$YEAR.",".$FILE.",".$IP;}
                          #completed sessions
if ($STATUS =~ m "c" ){$completed {$USERNAME}   = $TIME.",".$YEAR.",".
$IP;}

                           # incoming
if ($DIRECTION eq "i"  ){$incoming {$USERNAME}   = $TIME.",".$YEAR.",".
$FILE.",".$SIZE.",".$IP;}
                          #Outgoing      this is where we log all
outgoing xfers
if ($DIRECTION eq "o"){$outgoing {$USERNAME}   = $TIME.",".$YEAR.",".
$FILE.",".$SIZE.",".$IP;}

                                   #Masked Options  with file
extensions
#if ($DIRECTION eq "i" and $STATUS eq "c" ){$ {$USERNAME.",".
$MASKFILE} = $FILE.",".$TIME.",".$YEAR.",".$IP.",".$STATUS;}
   }
}
   close(FH);

#}
open(OUTPUT, '>', $incoming) or die("Could not open log file.");
for my $key ( sort %incoming) { if ($incoming{$key}) { print OUTPUT
"$key,$incoming{$key}\n";}}
close(OUTPUT);
open(OUTPUT, '>', $outgoing) or die("Could not open log file.");
for my $key ( sort %outgoing) { if ($outgoing{$key}) { print OUTPUT
"$key,$outgoing{$key}\n";}}
close(OUTPUT);
open(OUTPUT, '>', $failedlog) or die("Could not open log file.");
for my $key ( sort %failures) { if ($failures{$key}) { print OUTPUT
"$key,failures{$key}\n";}}
close(OUTPUT);
open(OUTPUT, '>', $completedlog) or die("Could not open log file.");
for my $key ( sort %completed) { if ($completed{$key}) { print OUTPUT
"$key,$completed{$key}\n";}}
close(OUTPUT);
#open(OUTPUT, '>', $) or die("Could not open log file.");
#for my $key ( sort %) { if (${$key}) { print OUTPUT "$key,${$key}
\n";}}
#close(OUTPUT);
print "\nFinished Processing Logfiles for $dateroot at " .
(localtime ) ."\n\n";
print "This script took ". (time - $^T)/60 ." minutes \n"



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to