I have a problem in which I have to pass input to a Python script that must not terminate. Therefore I need to pass arguments to the Python script while it is running. The Python script will also not be executed in the same PHP script so it cannot incorporate any sort of expect script due to expect requiring that you spawn the process in the same script! I have full access to the PHP and Python scripts so I can modify them at will. I also would not prefer hacky ways like making the PHP write to a text file and having the Python script read the commands from the file. Is their any less hacky way to do this?
You can use screen command to run the python script, then connect to the screen session anytime later from php with expect.
PHP Passing Input to Runing Python Script