1

I have written a python script (mail.py) to send email in python, and I have written another file to submit action. I need that the file mail.py should run in background. 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

1 Answer 1

1

You must set full path to python's interpreter like:

 shell_exec('/usr/bin/python mail.py &');
Sign up to request clarification or add additional context in comments.

5 Comments

how can i check that this command is running in background or not. because still it is not sending any mail but sending using command line
@lord_linus you can't using shell_exec. other methods include interprocess communication with mail.py, checking pid of mail.py, or make mail.py write a log and the read that log with php
hey now mail is being sent but I am getting one problem that I am doing two task: one is to submit the form and display some data and another is to send a mail in background. but when i am clicking to submit the form then it is waiting for sending the mail. but i need that the data should be displayed first and it should not wait for send mail
@VladBalmos whats the problem in sheel_exec()
shell_exec returns only the output of the command after it has executed. You are executing the ptyhon script in background, thus shell_exec returns imediatly without providing any output. So you can't know for sure if execution was successful or not

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.