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的问题 但试了试其他的命令就可以 什么个情况?shellphp
tar -zxvf update.tgz
#cp /var/www/wode/shell/update.sh /var/www/wode/tmp/shell目录下 update.sh update.tgz
php执行之后没有把update.tgz解压 以为是shell的问题 但试了试其他的命令就可以 什么个情况?shellphp
cd /var/www/wode/shell/
tar -zxvf update.tgz
#cp /var/www/wode/shell/update.sh /var/www/wode/tmp/就行了
嗯,这样也可以。不过注意一点,如果你是这样:
php:
shell_exec('cd /var/www/wode/shell/');
shell_exec('sudo sh /var/www/wode/shell/update.sh');shell:
#!/bin/sh
tar -zxvf update.tgz
#cp /var/www/wode/shell/update.sh /var/www/wode/tmp/依然是不行的。在php中执行切换目录,执行完一次shell_exec后,一个会话就结束了。结束之前对于服务器环境的改变,只对shell_exec这一个会话有效。所以必须用shell去进行目录切换。