php shell_exec()命令不起作用 [英] php shell_exec() command is not working
问题描述
我正在尝试从php运行.sh文件. 我试着用shell_exec()来做.但它不起作用 我在堆栈溢出中提到了许多与此相关的问题,但无法解决
I am trying to run a .sh file from php. I tried doing it with shell_exec(). but its not working I refered many questions related to this in stack overflow but could not solve
我的php代码是(web.php)
my php code is(web.php)
<?php
echo shell_exec('/var/www/project/xxe.sh');
echo "done";
?>
仅打印完成.但它可以在终端上运行(php/var/www/project/web.php)
only done is printed. but it is working from terminal(php /var/www/project/web.php)
在xxe.sh中,我正在调用python文件
In xxe.sh I am calling a python file
python vin.py
我还将两个.sh n .py文件的文件许可权都更改为777. 请帮助
I have also changed the file permission to 777 for both .sh n .py files please help
推荐答案
如果它在shell中运行良好,我认为apache是chroot.所以php找不到/var/...
If it works well in shell, I think apache is chrooted. So php can't find /var/...
或者httpd用户的用户无权输入/var/...
Or user of httpd user does not have permission to enter /var/...
如果您擅长PHP.打开dir/var/...,然后readdir()并检查dir是否存在,并检查文件是否存在.
If you are good at PHP. Open dir /var/... And readdir() and check dir exists and check file exists.
此问题可能会对您有所帮助. 使用opendir()扫描/home/
This question might help you. scanning /home/ with opendir()
这篇关于php shell_exec()命令不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!