Thanks, Bill and Basil.
It works now. I did close the sub, it was just not included, sorry.
Stdout:
$ ./exploitD.pl 1 0
16/09/1997-17:26:45.562062time="" action="" orig="bedm-edn-650-pri"
i/f_dir="inb
ound" i/f_name="eth-s1p2c3" proto="udp" src="00.00.00.00"
dst="172.16.0.65" serv
ice="1023" s_port="1548" len="3" rule="3" has_accounting="0"
LogFileID="10446117
03" LogRecNum="1980000"
Code Snippit:
sub genOne {
my $index = shift;
my %data;
$data{'name'} = "test";
my $num = int(rand() * 100);
my $year = 1997 + intRand(5);
my $mon = intRand(12);
my $day = intRand(28) + 1;
my $date = "";
$date .= "0" if (int($day) < 10);
$date .= $day;
$date .= "\/$months[$mon]\/$year-";
print "$date";
$data{'LogFileID'} = '1044611703';
$data{'LogRecNum'} = $recNum++;
##$data{'time'} = "$date";
##-------------------
my $epochseconds = "0";
my $microseconds = "0";
my $second = "0";
($epochseconds, $microseconds) = gettimeofday;
($second, $minute, $hour) = localtime($epochseconds);
print sprintf("%02d:%02d:%02d.%06d", $hour, $minute, $second,
$microseconds);
##----------------------
#change the action value to be one of the alerts from the array
#$data{'action'} = (intRand(12) < 11) ? 'accept' : 'drop';
$data{'action'} = $alerts[intRand(45)];
if (needError($actionErrRate)) {
if (intRand(20) < 3) {
$data{'action'} = 'deny';
} elsif (intRand(20) < 5) {
$data{'action'} = ' accept ';
} elsif (intRand(20) < 5) {
$data{'action'} = 'a c c e p t';
} elsif (intRand(20) < 5) {
$data{'action'} = 'acc\'eptdeny';
} else {
$data{'action'} = badString();
}
}
-Kamal.
-----Original Message-----
From: $Bill Luebkert [mailto:[EMAIL PROTECTED]
Sent: Monday, October 04, 2004 5:49 PM
To: Kamal Ahmed
Cc: [EMAIL PROTECTED]
Subject: Re: Time in perl
Kamal Ahmed wrote:
> Bill,
>
> When I use your approach, I am getting an error:
>
> 25/02/2001-Use of uninitialized value in sprintf at ./exploitD.pl line
> 208. 17:14:33.016000 time="" action="" orig="bedm-edn-650-pri"
> i/f_dir="inbound" i/f_
>
> Line 208 and few lines around it are as below:
> my $epochseconds = "0";
> my $microseconds = "0";
> ($epochseconds, $microseconds) = gettimeofday;
> ($second, $minute, $hour) = localtime($epochseconds);
> print sprintf("%02d:%02d:%02d.%06d %s", ## ----- THIS IS Line
208
> $hour, $minute, $second, $microseconds);
Drop the last %s on that line (it was probably for the timezone in the
original code).
use Time::HiRes qw(gettimeofday);
my ($epoch, $usecs) = gettimeofday;
my ($second, $minute, $hour) = localtime $epoch;
print sprintf "%02d:%02d:%02d.%06d\n", $hour, $minute, $second, $usecs;
__END__
--
,-/- __ _ _ $Bill Luebkert
Mailto:[EMAIL PROTECTED]
(_/ / ) // // DBE Collectibles Mailto:[EMAIL PROTECTED]
/ ) /--< o // // Castle of Medieval Myth & Magic
http://www.todbe.com/
-/-' /___/_<_</_</_ http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs