1

Ok before the flaming starts I did some research here and at some other links: Run process with realtime output in PHP

This is what I am currently using:

<?php
$descriptorspec = array(
0 => array("pipe", "r"),  // stdin
1 => array("pipe", "w"),  // stdout
2 => array("pipe", "w"),  // stderr
); 
flush(); ?>

<?php $process = proc_open($_POST['field1'], $descriptorspec, $pipes, dirname(__FILE__), null);?>

<?php $stdout = stream_get_contents($pipes[1]); fclose($pipes[1]); $stderr = stream_get_contents($pipes[2]); fclose($pipes[2]); ?>

This works fantastic for outputting any stdout and stderr from a console application to my webpage, however, due to what I am assuming is buffering it does not update in realtime. I have tried the methods in the link I posted and a similar method in Ajax but neither would update in realtime, just wait for all of the input to finish then display on the page.

All I can come up with is that php is waiting for the proc_open() command to finish executing before it tries to do anything with the output.

Any insight would be much appreciated.

Thanks!

Community
  • 1
  • 1
Blackdragon1400
  • 413
  • 4
  • 18
  • This may sound weird but have you tried setting this to an iframe then using ajax and javascript timers just refreshing that frame every so often? – Cole Busby Jun 07 '13 at 21:07
  • Thats definitely an interesting idea, but wouldn't that mean that I should technically beable to see updates on my output if I refresh the page manually? Nothing even shows up until the process is complete. Even the php errors (if there is one) wont display until that process has run.... – Blackdragon1400 Jun 07 '13 at 21:14
  • 1
    Unfortunately that is just php, the best thing to do is try to chunk the file and reduce its size and see if that helps but there are no guarantees. – Cole Busby Jun 07 '13 at 21:23

0 Answers0