Frage

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?

War es hilfreich?

Lösung

  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
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top