Question

I want to execute a simulation program in PHP which is already installed the pc root. that means, I can execute it in any directory. I tried to execute it using shell_exec but I cant see any output, while when I run it from terminal it works anywhere. this program also will generate an image which later I want it to appear in the page which is not a big deal. but the problem is there is just an empty image created and no output values.

<?php
$output = exec('rpict -vp 0 0 0 -vd 0.01 0 1 -ab 2 -ad 2048 -ar 64 -as 64 -aa 0.1 -vv 180 -vh 180 -vth with_sun_12_30_13_30.oct > test.hdr'); 
echo "<pre>$output</pre>"; 
?>
Was it helpful?

Solution

It's possible that rpict isn't on the path of the user running the web server. Try replacing it with the full path. (You can find this by typing which rpict on most systems).

Like Devon says, turn error reporting up too, to make sure you're getting the full picture:

<?php
  error_reporting(E_ALL);
  $output = shell_exec('/path/to/rpict ...');
  echo "<pre>$output</pre>";
?>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top