为什么我不能使用PHP7运行shell命令?

2024-04-29 12:22:21 发布

您现在位置:Python中文网/ 问答频道 /正文

我在使用php7(PHP Version 7.0.33-0+deb9u3)运行使用shell_execexec的python脚本时遇到问题。你知道吗

如果我运行:var_dump(shell_exec("/usr/bin/python3 /home/pi/Documents/GTranslate/translator.py"));var_dump(shell_exec("/home/pi/Documents/GTranslate/translator.py"));
我收回NULL。你知道吗

用户权限没有问题

我已经检查了运行的权限:

$scriptPath = "/home/pi/Documents/GTranslate/translator.py";
var_dump(array(
    'file' => is_file($scriptPath),
    'readable' => is_readable($scriptPath),
    'executable' => is_executable($scriptPath)
));

我得到了一切真实的东西。你知道吗

缺少safe_modephp.ini文件你知道吗

在我的php.ini文件(如phpinfo();所示)没有类似safe_mode的字段。从PHP 5.4.0开始读取PHP Wiki函数已被删除。你知道吗

shell_exec()正在工作

函数shell_exec()没有被禁用,因为如果我运行命令:

echo shell_exec("ls -halt /home/pi/Documents/GTranslate/translator.py");

我得到了回报:

-r-xr-x--x 1 pi pi 1.7K Aug 11 12:13 /home/pi/Documents/GTranslate/translator.py

问题出在哪里?


Tags: py权限homeisvarpishelldump