Well Disregard the above script I made changes that I think were
needed, but I still have no output in the .csv files

#!/usr/bin/perl
#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 %fields;
my %incoming;
my %outgoing;
my %logfiles;
             #Time Measured
print "Started Processing Logfiles for $dateroot at " . (localtime
time) ."\n\n";
             #Open Log File Dir to Read .log file(s)
opendir (DIR, ".") or die "$!";

my @logfiles = grep {/xferlog\.$dateroot.*/}  readdir (DIR);
close DIR;

           #Start Log Processing
foreach my $logfile (@logfile) {
   print "Started Processing: $dateroot at " . (localtime time) ."\n";
   open(FH,"./$logfile") or die "$!";
   while (<FH>){
                my $line = $_;
                chomp($line);
                my @fields = split / /, $line; #This is where we look
for the . extensions from the file name

              #My Ftp Status Log Values
                foreach ($line) {
                my $TIME  =$fields[0],$fields[1],$fields[2],
$fields[3];
                my $Year = $fields[4];
                my $TRANSFER= $fields[5];#this value is in seconds
                my $IP = $fields[6];
                my $SIZE = $fields[7];    #filesize
                my $FILE = $fields[8];    #filename and path
                my $TYPE = $fields[9];    #A= ascii B = binary
                my $DIRECTION = $fields[11]; #Outgoing, Incoming
                my $USERNAME = $fields[13];
                my $STATUS= $fields[17];   #c = completed  i=
incomplete
              # my $MASKFILE = $FILE;
              #  my $MASKFILE =~ s/\d/#/g;

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

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

                                   #Masked Options  with file
extensions
#if ($DIRECTION eq "i" and $STATUS eq "c" ){$completedlog
{$USERNAME.",".$MASKFILE} = $FILE.",".$TIME.",".$YEAR.",".$IP.",".
$STATUS;}
                }
                next;
   }
   close(FH);
}
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, '>', $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, '>', $loginsinlog) or die("Could not open log file.");
for my $key ( sort %loginsin) { if ($loginsin{$key}) { print OUTPUT
"$key,$loginsin{$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);
print "\nFinished Processing Logfiles for $dateroot at " . (localtime
time) ."\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