简体   繁体   English

从PHP脚本调用python脚本

[英]Call a python script from a PHP script

I have written a python script (mail.py) to send email in python, and I have written another file to submit action. 我已经编写了一个Python脚本(mail.py)以python发送电子邮件,还编写了另一个文件来提交操作。 I need that the file mail.py should run in background. 我需要文件mail.py应该在后台运行。 when I am writing the follwing code 当我写下面的代码时

$result=shell_exec('python mail.py&');
                echo $result;

then there is no response but when i am running the file python mail.py & then it is running successfully 然后没有响应,但是当我运行文件python mail.py &它运行成功

您必须像这样设置python解释器的完整路径:

 shell_exec('/usr/bin/python mail.py &');

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

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