Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

command not found - error in exec() command

Tags:

php

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.

like image 541
sathish Avatar asked May 05 '12 05:05

sathish


People also ask

Why is command not found?

There could be three possible reasons why it cannot find the command: It's a typo and the command name is misspelled. The command is not even installed. The command is basically an executable script and its location is not known.

What is find exec command?

The best feature of the find command is its exec argument that allows the Linux user to carry out any command on the files that are found. In other words, actions can be performed on the files that are found.

What does exec do in terminal?

Linux exec Command Syntax If an argument is present, the exec command replaces the current shell with the executed program. In a Bash script, any commands after do not get executed. If no command argument is present, all redirections occur in the current shell.


2 Answers

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.

like image 94
andrewsi Avatar answered Nov 04 '22 10:11

andrewsi


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)
like image 3
oezi Avatar answered Nov 04 '22 11:11

oezi