我在CentOS 6上运行并使用Apache2。
如果我从命令行运行以下命令,它将完美运行
wp --help
但是,当我尝试从php脚本调用的shell文件中运行'wp'命令时,我收到命令未找到错误。
test.sh
#!/bin/bash
echo $PATH
whereis wp
wp --help
test.php的
<?php
system("./test.sh >> test.log 2>&1");
?>
输出将是( test.log )
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/bin/wp
wp: /usr/local/bin/wp
./test.sh: line 4: wp: command not found
我尝试了每种权限组合,但我仍然遇到此错误
答案 0 :(得分:0)
您可以尝试将wp
的完整路径保存到某个变量中,然后在您的脚本中使用它:
#!/bin/bash
WP=`whereis wp | cut -d ' ' -f 2`
$WP --help