php执行Linux的shell脚本

技术文章2年前 (2023)更新 gyx131
240 0 0

php执行Linux的shell脚本   代码如下:

test.sh 为脚本文件

需要注意  exec()函数是否禁用。宝塔面板默认禁用。

<?php

$shell = "sh ./test.sh";

exec($shell, $result, $status);

$shell = "<font color='red'>$shell</font>";

echo "<pre>";

if( $status ){

echo "shell命令{$shell}执行失败";

} else {

echo "shell命令{$shell}成功执行, 结果如下<hr>";

print_r( $result );

}

echo "</pre>";

?>
© 版权声明

相关文章

暂无评论

暂无评论...