문제

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?

도움이 되었습니까?

해결책

  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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top