I am running some python script from within a PHP script using PHP's
states that the all output of the program is written to the
array. This works fine, however, if the Python code raises an exception/error, the function seems to just return NULL, without any information on the exception.
x = 1/0 #This will raise an error
Running it from the interactive PHP shell
yields the following:
php > $output = '';
php > $ret_val = exec('python run_python.py', $output);
Traceback (most recent call last):
File "run_python.py", line 2, in <module>
x = 1/0
array only contains
This is OK for the interactive shell, but I am running the code from a web interface and the error information is never displayed. Is there any way to capture that error and then display it using
I did try shell_exec
, but without success.