In php there are several methods to execute a shell command:
- system()
- passthru()
- shell_exec()
- exec()
First two displays output but doesn’t return it.
Last two returns output but doesn’t display it.
I want to run shell command which require a lot of time but it displays some output so I know it doesn’t hang. However at the end I want to process this output in php. If I choose one of first two I won’t get output so I will be unable to process it in php. If I run one of the last two I will be able to process output however my program will hang very long time without outputting anything.
Is there a way to run a shell command which will display output immediately and return it?
Maybe this one will interest you?
proc_open()– http://www.php.net/manual/en/function.proc-open.phpAnd here is a handy snippet which might work for you (it’s copied from the comments on the site I gave you the link to):