Answer the question
In order to leave comments, you need to log in
How to automate a console program?
There is a console program that, when launched, expects input (pressing a number) and Enter. T their mode does not work, configuration error. Can it be automated?
How to write correctly? I present it like this
import time
# ...
h = process.open("progname")
time.sleep(10)
h.write("2\n")
time.sleep(30)
h.write("1\n")
sleep(5)
h.close()
Answer the question
In order to leave comments, you need to log in
from subprocess import Popen, PIPE, STDOUT
fil = "\n" * 10
p = Popen(['python', 'prog.py'], stdout=PIPE, stdin=PIPE, stderr=STDOUT)
p.communicate("1\n2" + fil)[0]
p = Popen(['python', 'prog.py'], stdout=PIPE, stdin=PIPE, stderr=STDOUT, shell=True)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question