0

I have a python program that i want to execute from php I already tried "exec,escapeshellcmd,shell_exec,passthru,popen" but no one is giving result.

i already execute "hello word" program successfully but the program that i needed is not executing and not displaying any error.

echo $python = exec("python python/interactive.py");//this file not working
echo $python = passthru("python python/python.py ");// this is working with hello world.
$output = shell_exec($command);
echo $output;
5
  • Yes, exec and friends are the right way to tackle this. What is the error you get? Commented Jan 30, 2017 at 11:55
  • i'm not getting any error. Commented Jan 30, 2017 at 12:00
  • can you share your php code, at least the line where you call exec? Commented Jan 30, 2017 at 12:01
  • I added code also. Commented Jan 30, 2017 at 12:04
  • what is python/interactive.py doing? It sounds like it needs a terminal, which of course is not present if you run that python program within a webserver Commented Jan 30, 2017 at 15:44

1 Answer 1

0

I suggest that you look into a python web framework like Flask or Django which are the two main ones if you want to be executing python scripts on the web.This would be the best way to do it.

Sign up to request clarification or add additional context in comments.

1 Comment

actually thing is that the python program that i am using that in not a web app otherwise i not need to execute python in php.

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.