A
Andy
Greets
Q; I am trying to learn how to define some variables
The basis of this script is to Scrub log files for ftp logins,
seperate the successful logins
Then create an array ( I hope the right terminology) to seperate it
I hardcoded the log file, because I am looking for a way for it to
scrub *.logs on a server
but ...hey step by step right.
Fields: date time c-ip cs-username cs-method cs-uri-stem sc-status sc-
bytes cs-host
2008-01-20 00:00:02 x.x.x.x 0598_Andy [6952041]sent /
0598_Andy/qff0598.zip 226 0 -
This field 226 0 - is a successful login
My plan is to scrub the logs, export to file.
sort fields into variable.
I hope in the end to get
1..log of successful logins
2.log of last successful login ( I think I am going to try date
comparison from most recent to last.)
3 be able to parse the fields and get data.
I know that there are those of you who are advanced, I would
appreciate any directions or help.
Again I am trying to put this together this is what I have so far.
#!/usr/bin/perl
use strict;
use warnings;
open(INPUT, '<', "ex080120.log")or die("Could not open log file.");
open(OUTPUT, '>',"ftpacct.log")or die("Could not open log file.");
my $extractedLine;
while (<INPUT>) {
my $line = $_;
if ($line =~ m/^(.+226\s+0\s+-\s+.*)$/) {
print OUTPUT "$1\n";
}
}
close(INPUT);
close(OUTPUT);
exit;
Q; I am trying to learn how to define some variables
The basis of this script is to Scrub log files for ftp logins,
seperate the successful logins
Then create an array ( I hope the right terminology) to seperate it
I hardcoded the log file, because I am looking for a way for it to
scrub *.logs on a server
but ...hey step by step right.
Fields: date time c-ip cs-username cs-method cs-uri-stem sc-status sc-
bytes cs-host
2008-01-20 00:00:02 x.x.x.x 0598_Andy [6952041]sent /
0598_Andy/qff0598.zip 226 0 -
This field 226 0 - is a successful login
My plan is to scrub the logs, export to file.
sort fields into variable.
I hope in the end to get
1..log of successful logins
2.log of last successful login ( I think I am going to try date
comparison from most recent to last.)
3 be able to parse the fields and get data.
I know that there are those of you who are advanced, I would
appreciate any directions or help.
Again I am trying to put this together this is what I have so far.
#!/usr/bin/perl
use strict;
use warnings;
open(INPUT, '<', "ex080120.log")or die("Could not open log file.");
open(OUTPUT, '>',"ftpacct.log")or die("Could not open log file.");
my $extractedLine;
while (<INPUT>) {
my $line = $_;
if ($line =~ m/^(.+226\s+0\s+-\s+.*)$/) {
print OUTPUT "$1\n";
}
}
close(INPUT);
close(OUTPUT);
exit;