当前位置:Gxlcms > PHP教程 > 神奇的没法解压之shell_exec

神奇的没法解压之shell_exec

时间:2021-07-01 10:21:17 帮助过:23人阅读

神奇的无法解压之shell_exec
php:

shell_exec('sudo sh /var/www/wode/shell/update.sh');

sh:

#!/bin/sh
tar -zxvf update.tgz
#cp /var/www/wode/shell/update.sh /var/www/wode/tmp/

shell目录下 update.sh update.tgz
php执行之后没有把update.tgz解压 以为是shell的问题 但试了试其他的命令就可以 什么个情况? shell php


------解决方案--------------------
/var/www/wode/shell/ 没权限吧,php是什用户组,目录又是什么用户组……
------解决方案--------------------
把update.tgz写成绝对路径试试看。在浏览器上用php执行的时候,当前目录是php的脚本目录,用cli模式执行时,当前目录是php二进制文件的目录。而并不是你那个shell脚本的所处目录。

人气教程排行