PHP shell_exec is not responding on python command line

两盒软妹~` 提交于 2021-02-11 16:59:22

问题


Hi I am running shell_exec on my PHP Application, Here is the code,

$path = "C:/scripts/";
chdir($path);
$py_commonscript = 'python Common_Script.py';
$exec = shell_exec($py_commonscript);

echo "<pre>$exec</pre>";

This code doesn't give any result and does not generate a file. When I tried running manually on the command line it is working and was able to generate a file.

I tried to execute this one below and it was able to display some result.

$sample = shell_exec('ls -lart');
echo "<pre>$sample </pre>";

I am wondering why the command for $exec is not being triggered or run.


回答1:


The most likely cause is that your PHP code isn't inheriting a %PATH containing python.exe. Try print getenv('PATH'); or just use the full path to python.exe in your command line.



来源:https://stackoverflow.com/questions/65612905/php-shell-exec-is-not-responding-on-python-command-line

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!