简体   繁体   中英

-bash: shell_exec: command not found , shell_exec is not running on linux terminal

shell_exec is not running on linux terminal

try to run below commands

[root@localhost conf]# shell_exec
-bash: shell_exec: command not found
[root@localhost conf]# shell_exec("pwd")
-bash: syntax error near unexpected token `"pwd"'
[root@localhost conf]#

You're trying to execute PHP directly on the command line without using the PHP packaging, so the bash shell is attempting to execute it and doesn't recognize the PHP function.

You need to run shell_exec() in a PHP file or use the appropriate PHP CLI syntax. For example, you can pass -r to the php command, which allows you to run code.

myusername:~$ php -r 'echo shell_exec("pwd");'
/home/myusername
myusername:~$ 

Or you can use the built-in REPL.

myusername:~$ php -a
Interactive shell

php > echo shell_exec('pwd');
/home/myusername
php > 

Also note the use of echo here since the successful result will return a string that we want to see.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM