I have a huge text file with info about when people login and my super, wants a perl script to be able to find certain people based on serial #, user name, or view all within a range of dates.
For some reason I cannot get it to find anything inside of the text.
I have anoter script that finds when the login was rejected and this is based off that one but this one fails.
Any help would be appreciated,
Nate
an example line of the text file is:
303426,11/10/2003,03:30:30,11/09/2003,22:30:30,1011,"Person's Name","userID","serial#(12 digit number)","","","5hint-vp01","psysadm-rsa01p","Person's Name",0,0,"Access DENIED"
the program as is:
#!c:\perl\perl.exe
print 'Enter 1 to print to screen, 2 to print to a file:';
$answer = <STDIN>;
print 'Enter 1 to search by Serial #, 2 to search by userID, 3 to search by date range:';
$answer2 = <STDIN>;
if($answer2 == 1) {
print 'Enter Serial #: ';
$serial = <STDIN>;
print "$serial";
}
elsif($answer2 == 2) {
print 'Enter the userID: ';
$user = <STDIN>;
print "$user";
}
else{
print 'Enter the beginning date: ';
$begin = <STDIN>;
print 'Enter the end date: ';
$end = <STDIN>;
print "$begin";
print "$end";
}
$filename = 'erslog2';
$filename2 = 'results';
open(FILE, "$filename");
open(FILE_HANDLER, ">$filename2");
@lines = <FILE>;
foreach $word (@lines) {
if($answer == 1) {
if($answer2 == 1) {
if($word =~ $serial) {
print "$word ";
}
}
elsif($answer2 == 2) {
if($word =~ $user) {
print "$word ";
}
}
}
elsif {
if($answer2 == 1) {
if($word =~ $serial) {
print FILE_HANDLER "$word ";
}
}
elsif($answer2 == 2) {
if($word =~ $user) {
print FILE_HANDLER "$word ";
}
}
}
else
print "Feature not implemented yet";
}
if($answer == 2) {
print "Everything is in a file called results ";
}
For some reason I cannot get it to find anything inside of the text.
I have anoter script that finds when the login was rejected and this is based off that one but this one fails.
Any help would be appreciated,
Nate
an example line of the text file is:
303426,11/10/2003,03:30:30,11/09/2003,22:30:30,1011,"Person's Name","userID","serial#(12 digit number)","","","5hint-vp01","psysadm-rsa01p","Person's Name",0,0,"Access DENIED"
the program as is:
#!c:\perl\perl.exe
print 'Enter 1 to print to screen, 2 to print to a file:';
$answer = <STDIN>;
print 'Enter 1 to search by Serial #, 2 to search by userID, 3 to search by date range:';
$answer2 = <STDIN>;
if($answer2 == 1) {
print 'Enter Serial #: ';
$serial = <STDIN>;
print "$serial";
}
elsif($answer2 == 2) {
print 'Enter the userID: ';
$user = <STDIN>;
print "$user";
}
else{
print 'Enter the beginning date: ';
$begin = <STDIN>;
print 'Enter the end date: ';
$end = <STDIN>;
print "$begin";
print "$end";
}
$filename = 'erslog2';
$filename2 = 'results';
open(FILE, "$filename");
open(FILE_HANDLER, ">$filename2");
@lines = <FILE>;
foreach $word (@lines) {
if($answer == 1) {
if($answer2 == 1) {
if($word =~ $serial) {
print "$word ";
}
}
elsif($answer2 == 2) {
if($word =~ $user) {
print "$word ";
}
}
}
elsif {
if($answer2 == 1) {
if($word =~ $serial) {
print FILE_HANDLER "$word ";
}
}
elsif($answer2 == 2) {
if($word =~ $user) {
print FILE_HANDLER "$word ";
}
}
}
else
print "Feature not implemented yet";
}
if($answer == 2) {
print "Everything is in a file called results ";
}