tommycahir1
Programmer
hi all i trying to put the cgi script to sleep for 60 seconds but it doesnt appear to work as it calls the save_graph function almost immediately..
any ideas on what i have done wrong..
my $index = 1;
while ($index <= $NoOfIf )
{
my $pid = fork();
die "Cannot fork: $!" unless defined($pid);
if ($pid == 0)
{
# Child proces
recieved_packets($now,$then,$index);
exit(0);
}
$index++;
}
my $graphxlabel = "Time";
my $graphylabel = "No. Of Packets Recieved";
my $graphtitle = "No. Of Packets Recieved On Interface No. ";
my $infile = "indata";
sleep(60);
save_graph($graphtitle,$graphxlabel,$graphylabel,$NoOfIf,$infile);
print_graph;
To explain the code above better would be the recieved packets creates a file possibly multiple files if there are more than one process. then the script should sleep for 60 seconds(due to save file trying to read files that werent created yet).then read these created files and save a graph image then print_graph displays these images to screen ..
any ideas on what i have done wrong..
my $index = 1;
while ($index <= $NoOfIf )
{
my $pid = fork();
die "Cannot fork: $!" unless defined($pid);
if ($pid == 0)
{
# Child proces
recieved_packets($now,$then,$index);
exit(0);
}
$index++;
}
my $graphxlabel = "Time";
my $graphylabel = "No. Of Packets Recieved";
my $graphtitle = "No. Of Packets Recieved On Interface No. ";
my $infile = "indata";
sleep(60);
save_graph($graphtitle,$graphxlabel,$graphylabel,$NoOfIf,$infile);
print_graph;
To explain the code above better would be the recieved packets creates a file possibly multiple files if there are more than one process. then the script should sleep for 60 seconds(due to save file trying to read files that werent created yet).then read these created files and save a graph image then print_graph displays these images to screen ..