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>"; ?>
© 版权声明
文章版权归作者所有,未经允许请勿转载。
相关文章
暂无评论...