I'm trying to get a simple Python script to output to PHP in real-time, and I find myself having trouble to accomplish it.
The script is nothing fancy, for testing purposes, just this:
#!/usr/bin/python
import time
time.sleep(1)
print "message 1"
time.sleep(1)
print "message 2"
time.sleep(1)
print "message 3"
time.sleep(1)
print "message 4"
I've tried calling the Python code several ways. It seems when I try to run it from:
<?php
$output=shell_exec("/var/www/html/output.py");
print_r($output);
?>
It seems to wait for 4 secondes, and outputs the entire thing.
I've tried messing around with the ob_flush and flush() PHP commands, but I'm not able to get the effect that I want, it's essentually the same as the shell_exec()
And input would be greatly appreciated!