简体   繁体   English

exec()php,sh脚本部分运行

[英]exec () php, sh script runs partially

sorry for bad english.. 对不起,英语不好。

i have php file like this: 我有这样的PHP文件:

<?php

exec(`sh /tmp/script.sh`); 

echo "Work!";
?>

and this is the script: 这是脚本:

#!/bin/bash

url="http://someweb.com/get.php?user=user&pass=pass";

wget -O /tmp/file.txt $url

sed -i 's/#Test_file/Ok_Test_file/' /tmp/file.txt

cp /tmp/file.txt /var/www/_client/personale/file.txt

Now when load file.php to the browser, the script works ,but only commands wget and sed are performed , except cp which doesn't work..does not copy the file! 现在,当将file.php加载到浏览器时,该脚本可以工作,但是仅执行wget和sed命令,除了cp无效。.不会复制文件! If i run the script to terminal manually (Debian 8) all cmd are executed... Where is the problem? 如果我手动将脚本运行到终端(Debian 8),则所有cmd都将执行...问题出在哪里? Thanks. 谢谢。 Joele 乔尔

PHP likely does not have permission to execute the command. PHP可能没有执行该命令的权限。 Try using sudo to execute the command. 尝试使用sudo执行命令。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM