1

I have a webpage which has some input tags which are passed to PHP to validate it and then php creates a command for another Python script to run and command is executed using $output = shell_exec($cmd); The Python script is a Selenium script which gives some output/status of what's going on while it's doing.

My question is that is there any way that I can use PHP to shell_exec the command created and display the output of Python script continuously? I can get all the output after the command is executed and not while the script is executing.

I searched on Google but didn't find any help. I read these answers, but they are not helping me...

Python: how to show results on a web page?

Display python script output to HTML page

How to run python script in webpage

How to continuously display Python output in a Webpage?

I don't want to use Flask or Django because my rest of the code is in PHP.

5
  • 1
    you can try enabling websockets in your python script and catch output of your script through websocket in your php script. Commented Aug 23, 2019 at 9:14
  • You can construct such things setting up a socket based client process forking instead of using shell_exec() which per documentation first executes and the returns. Take a look at the proc_open function php offers: php.net/manual/en/function.proc-open.php You will find various examples on the internet for this. Commented Aug 23, 2019 at 9:15
  • shell_exec etc. don't use this method. Just create another loopback service for easily manage/cache control. Commented Aug 23, 2019 at 10:08
  • Thank you all for giving various suggestions. Can anyone please give some code? Commented Aug 23, 2019 at 10:56
  • I am still not able to use proc_open or popen in PHP. Can anyone please help me with the code and how to use the functions? I have not understood anything from the documentation... Commented Sep 1, 2019 at 7:26

0

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.