0

Php pages on /var/www/mypage say system("foo.sh"). foo.sh is located on /one/dir and contains command bar.sh that is in /other/dir. For a user using ssh connection and having /one/dir and /other/dir in PATH everything works.

Now, if I put

<Directory /var/www/mypage>
SetEnv PATH . . . :/one/dir:/other/dir

to Apache config, then print getenv("PATH"); on /var/www/mypage/mytest.php shows that /one/dir and /other/dir are in the path. But system() still does not found foo.sh. What's wrong? And after this also foo.sh should see the same PATH so that it will find bar.sh.

I am setting this on Ubuntu 20.04, PHP 7.4.3.

  • Does this answer your question? [How do I run a shell script without using "sh" or "bash" commands?](https://stackoverflow.com/questions/8779951/how-do-i-run-a-shell-script-without-using-sh-or-bash-commands) – Justinas Aug 26 '22 at 08:32

1 Answers1

0

Most likely because just executing > foo.sh would show command not found: foo.sh.

You should specify full/relative path: system('./foo.sh');

Justinas
  • 41,402
  • 5
  • 66
  • 96