On Tue, Aug 4, 2009 at 12:43 PM, Megan Land <[email protected]> wrote:
> Hi,
>
> I'm working on a python script to automate a program we run at work. The
> program is run from one command. The only problem is that it asks you to hit
> enter to continue after it runs. Is there a way I can do this?
>
> If at all possible I need a program that will work on Windows and Linux (I
> know a tall order). I'm trying to keep this simple but if I have to use two
> different programs I will.
>
I just tested and this seems to work:
import subprocess
p = subprocess.Popen(['python', 'asdf.py'], stdout=subprocess.PIPE,
stdin=subpro
cess.PIPE)
p.stdin.write('\r\n')
print p.stdout.readlines()
- the contents of asdf.py are just these:
raw_input("Press enter to continue")
print "Works!"
HTH!
-Wayne, who just learned a little something about the subprocess module
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor