I’m have a long-running perl script that outputs the percentage complete. How do I show the completion status real-time on a php page?
Example:
perl:
my $i = 0;
for $i (1 .. 6) {
print "$i\n";
sleep 1;
}
print "script end\n";
exit;
php:
echo passthru('perl testprint.pl');
This works to display the output, but not real-time.
Modify your perl script to pipe the output to a flat file. Use a php script to parse this file and output in whatever format you want.
You could call the php script from your html page using ajax, or if you save the perl script in the server’s CGI directory you can call it directly without the need for the extra php file.
Lastly, create a nifty progress bar and profit.