I am running a CGI script that executes external script. This external script forks and exits itself to become deamon and writes its responses to log file. This is necessary to take care of timout issues.
Now, I read from the log file in a do-while loop and check for end of marker or just print "." , so that browser doesnt timeout, even if the execution of script takes 30 minutes.
I tried to use sleep between do-while loop, so tha status is checked every minute. Problem is that when I insert sleep, somehow CGI waits at thes tep, where I execute
external script, and does not go to do-while loop. (NOTE: Sleep is in do-while loop)
Code is below:
`./install_rootfs.pl $ROOT_FS $REPOSITORY $TARGET $in{toolchain}`;
# if sleep introduced below, nothing gets printed after install-rootfs command
print "<li> RG ";
my $LOGFILE = "log_to";
my $LTP_compilation_over = 0;
do {
eval {
open (LOG, "$LOGFILE") ¦¦ die ("Cannot open file");
my @log = <LOG>;
close (LOG);
if ($log[$#log] =~m/Status=100/) {
print "Compilation over";
$LTP_compilation_over = 1;
}
};
# problem with sleep
sleep 10;
} while ($LTP_compilation_over!= 1);
Any other ideas.
Kindly help. I have spent 2 days trying to find logical solution to this
~rajat garg
You mentioned that you just print a '.' character to keep the browser awake, try printing ".\n". New line will flash the buffer and output. That would work on the command line, but I don't think it will work in the browser though. You need to use nph for that.
this is all imo, i haven't tested it.