sathish
sathish

Reputation: 6765

command not found - error in exec() command

I run this from php file

exec("epm package");

i got below error in error_log

sh: epm: command not found

I tested manually in terminal it works fine.

Upvotes: 13

Views: 8975

Answers (3)

oezi
oezi

Reputation: 51807

sounds like epm isn't in the PATH environment variable for the user your webserver is running (probably apache). to solve this, do one of these:

  • add the path to epm to the webserver-users PATH
  • provide the full path for your command to be executed (/whatever/folder/epm package)

Upvotes: 3

andrewsi
andrewsi

Reputation: 10732

Try putting in a full path name:

exec("/path/to/epm package");

Your webserver process won't necessarily be set up with the same configuration as your own account.

Upvotes: 15

jaredhoyt
jaredhoyt

Reputation: 1575

I'm assuming the user you are testing with in the terminal and the webserver user running your PHP are different. You need to make sure directory for the epm package is exported to the PATH environment variable for the webserver user.

Upvotes: 2

Related Questions