sh是linux,unix命令。
用途:调用缺省 shell。
语法:请参阅 ksh 命令的语法。将 /usr/bin/sh 文件链接到 Korn shell。
描述:sh 命令调用缺省 shell 并使用它的语法和标志。链接到 /usr/bin/sh 路径的 shell 是缺省的 shell。
linux下输入visudo
然后我们在最后追加
apache ALL=NOPASSWD:/bin/sh
然后
php执行exec("/usr/bin/sudo /bin/sh /xxx/xxx.sh")
/xxx/xxx.sh 是你要执行的脚本
php提供如下几个函数:
shell_exec
$output = shell_exec('ls -lart');
echo "$output";
exec
echo exec('whoami');
system
$last_line = system('ls', $retval);
passthru
passthru('wc -w *.txt | head -5',$returnval);
详细解释可以查看手册。
函数:exec ( string $command [, array &$output [, int &$return_var ]] );
echo exec('whoami');
exec('/root/test.sh');
exec("/somewhere/dosomethings.sh");