I want to run an exe file on my server and return the output to the browser screen. The exe file takes a input file and then returns data on the screen.
Why is this code not working?
$output = shell_exec('myprogram < INP.DAT');
echo "<pre>" . var_export($output, TRUE) ."</pre>\\n";
It displays "NULL" on the browser screen. I have also tried exec(). There it returns "Array()".
this should work:
One of the comments on the
shell_exec
manual page says:It may be disabled if PHP is in safe mode.
You can check your server's PHP settings with the
phpinfo()
function.Is myprogram available from a default shell? Is it in a specific directory?
Try replacing
myprogram < INP.DAT
with/full/path/to/myprogram < INP.DAT
Sometimes these functions are disabled without the php are in safemode, you have to enable them in php.ini