Hello
I have a very simple python code cpt.py:
read the first item (printed by line 2) echo that value
which will be read by line 3, read the new line (line 4)
an do it twice since cpt.py loop 2 times.
I tried without success (since I am asking !)
JC
I have a very simple python code cpt.py:
for i in xrange(2): print i # line 2 ans = raw_input() # line 3 print ans # line 4I want to write another python program that run cpt.py,
read the first item (printed by line 2) echo that value
which will be read by line 3, read the new line (line 4)
an do it twice since cpt.py loop 2 times.
I tried without success (since I am asking !)
cmd = "cpt.py" p = subprocess.Popen(cmd,stdout=subprocess.PIPE,stdin=subprocess.PIPE,stderr=subprocess.PIPE) p.stdout.readline(ans) # read the print i (line 2) p.stdin.writelines(ans)# write it (line3) p.stdout.readline(ans) # read the print a (line 3) p.stdout.readline(ans) # read (line 2) second time p.stdin.writelines(ans)# write it(line 3) second time p.stdout.readline(ans) # read (ligne 3) second timeThank you very much
JC