Question

I have a bash script:

run.sh

#!/bin/sh
cd /var/www/project/bin/ 
CMD="./executable <full_path_to_file>;
$CMD

When I run this program from the terminal. (i.e. ./run.sh, it works fine)

However when I call it from PHP:

system("full_path_to_sh_file", $out);

It calls the script successfully, and even runs the executable, but now the executable throws an error saying that the supplied file can't be found.

Any ideas?

Était-ce utile?

La solution

  1. How do you run PHP script, from webserver or command line?
  2. If from webserver, what user is it run (httpd or apache?)
  3. Make sure the environment as same as when you are running from terminal (for example: same user)
  4. Try this if running as different user: sudo -u apache /fullpath/run.sh
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top