Here is an example of how to do interactive I / O using the command line. I used something similar to create a spell check based on a command line utility ispell:
f = popen2.Popen3("ispell -a")
f.fromchild.readline()
for word in words:
f.tochild.write(word+'\n')
f.tochild.flush()
line = f.fromchild.readline()
f.fromchild.readline()
status = parse_status(line)
suggestions = parse_suggestions(line)
The only problem is that it is a very fragile and trial and error process to make sure that you are not sending bad input and are processing all the different results that the program can produce.
source
share