I have this weird problem. The php
command is not found in one specific sitiation.
I try to call the command in three different ways. Only one of them fails:
Being user
john
I create a simple script which callsphp --version
. Then as userroot
I call that script like this:sudo -u john ./script.sh
This way thephp
command is not found.Being
root
I invoke the command directly like this:sudo -u john php --version
No problem here, the command does exist.I call the script directly as user 'john':
./script.sh
It works fine too.
What is causing this?
The problem happens with other users too, not just john
, and it happens on this particular machine only.
The OS is CentOS 5.9.
EDIT: Also, other commands like gcc
, perl
or python
don't present this problem. The php
command is the only one I found so far with the problem.
PATH
variable as your interactive shell. Typeecho $PATH
to see your current path variable, and set thisPATH
variable within the script.As for why the
PATH
variable isn't consistent between the two:bash
, consultman bash
and begin reading at theINVOCATION
section near the top of the file.