Centos执行shell命令返回127错误
- 在终端可以正常运行 web执行shell 返回127错误
解决方法
应该是运行环境和登录用户的运行环境存在差异造成的
在脚本执行之前,添加. /etc/profile,加载环境变量,问题解决
#!/bin/bash
. /etc/profile #脚本执行之前
#PHP
$cmd="sudo /www/wwwroot/uiw/shell/prt.sh";
system($cmd,$ret);
echo $ret; //返回1或者其他是失败 0是成功
网友评论