What I am trying to do is better explained here: Sending to the stdin of a program in python3
I am trying to send arguments to a program while it is open e.g:
rec.py
import sys
import time
while True:
print(sys.argv)
time.sleep(1)
send.py
import subprocess
program = Popen(['python.exe', 'rec.py', 'testArg'])
a = input('input: ')
a.communicate(b)
I want to be able to run send.py and type in my input. Say my input was 'cat', I would want the output to look like this when I run send.py
['rec.py', 'testArg']
['rec.py', 'testArg']
['rec.py', 'testArg']
cat <------- My input
['rec.py', 'testArg', 'cat']
['rec.py', 'testArg', 'cat']
['rec.py', 'testArg', 'cat']
['rec.py', 'testArg', 'cat']
ect..
Am I using the subprocess.Popen.communicate() incorrectly or is it something else?
Please help!
-Thanks