0

I've written a bash script that launches a browser on an xServer and takes a screenshot of the browsers. If I run it with the apache2 user (www-data) its working flawless, even when i use the php interactive shell and run it via shell_exec or exec its working perfectly. However when I run it from my php file via browser it does not seem to work properly. The script does not seems to run the xterm command (for launching the browser) and takes no screenshots, it only executes sleep and kill commands. I spent the whole day looking for a solution or at least a proper way to debug but i cant seem to fid anything

4
  • Have you added error_reporting(E_ALL); ini_set('display_errors', '1'); to the PHP script to debug it?
    – Jake N
    Jan 27, 2014 at 23:10
  • I doubt it wont help because the script is executed, i can see it running in the process list so i guess php wont show any errors. The script just seems to be executed inproperly or sth Jan 28, 2014 at 6:49
  • What the command you're running form the CLI?
    – Jake N
    Jan 28, 2014 at 11:17
  • comand is shell_exec('bash /home/daemon/daemon.sh > /dev/null &'); I've tried different commands like exec() or even a start bash script that starts the daemon.sh in background but nothing seem to work Jan 28, 2014 at 14:19

1 Answer 1

0

Turn on errors to start with

error_reporting(E_ALL);
ini_set('display_errors', '1');

Then change your command to

shell_exec('bash /home/daemon/daemon.sh');

The last part of your command pipes all output (including errors) to /dev/null - E.g to no where so you will not see any errors at all.

Do this and re-run the command and you should see errors.

1
  • I simply get a blank page. When I echo the shell_exec command i only see all my echos of my bash script, but still not any errors it produces Jan 29, 2014 at 13:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.