August 12th, 2005, 03:08 AM
Python calls program -- Program requires input
My python scripts calls a program using subprocess.call()
The program it calls requires input from the user -- Could I emulate the user typing that in, and pressing enter?
Like have the python script do it for them?
Unfortunatly the program doesn't allow putting the input in when you call it -- ie -- 'nano [filename]'
You can't determine what goes in the file from the cmd line (short of echo 'blah' > [filename]
August 13th, 2005, 04:02 AM
From your post it sounds like you need to manage the input and output steams of the sub-process. Check out the module documentation on this
August 13th, 2005, 04:37 PM
If your program just needs a fixed input read from stdin then you can do it with the subprocess module, as grim says.
If the program needs to interact with your program, for example it prints something and then your program types in a response, then you to use pexpect. This only works on unix systems or cygwin though.