[Tutor] Running a dos program with python
Armstrong, Richard J.
rarmstro at water.ca.gov
Thu Mar 11 00:22:39 CET 2010
Thanks Randy, maybe I should check out wxPython.
From: tutor-bounces+rarmstro=water.ca.gov at python.org
[mailto:tutor-bounces+rarmstro=water.ca.gov at python.org] On Behalf Of
Randy Raymond
Sent: Wednesday, March 10, 2010 3:06 PM
To: Tutor Python
Subject: Re: [Tutor] Running a dos program with python
I use wxPython, which allows a statement like:
wx.Execute('c:\shake91.exe "FLAC.txt" "a.txt" "b.txt"')
From: Armstrong, Richard J. <mailto:rarmstro at water.ca.gov>
Sent: Wednesday, March 10, 2010 4:51 PM
To: Wayne Werner <mailto:waynejwerner at gmail.com>
Cc: tutor at python.org
Subject: Re: [Tutor] Running a dos program with python
From: srilyk at gmail.com [mailto:srilyk at gmail.com] On Behalf Of Wayne
Werner
Sent: Wednesday, March 10, 2010 2:24 PM
To: Armstrong, Richard J.
Cc: tutor at python.org
Subject: Re: [Tutor] Running a dos program with python
On Wed, Mar 10, 2010 at 3:20 PM, Armstrong, Richard J.
<rarmstro at water.ca.gov> wrote:
Hello all,
This is my first post to the Tutor at python.org mailing list. I am in the
process of switching from Matlab to Python and there is one task that I
am having a hard time doing and cannot find the answer on the web. I
want to write a script in python that will open up a windows dos
program, send three inputs (file names) into program and then run it. I
know one way to open up the dos program with
os.system(r"c:\shake91.txt") but cannot do the rest.
Use the subprocess module:
http://docs.python.org/library/subprocess.html
untested, but should work:
subprocess.Popen([r'c:\shake91.txt', 'param1', 'paramN-1', 'paramN'])
if you want to communicate with the process you can add ,
stdout=subprocess.PIPE, stdin=subprocess.PIPE) to the function call.
Check the docs for more info.
HTH,
Wayne
Wayne,
It kindof works. I wrote
subprocess.Popen([r'c:\shake91.exe', 'FLAC.txt', 'a.txt', 'b.txt'])
The dos program pops up and if I hit the enter key three times then it
runs. How can I add these three "enters" into the script?
Thanks,
Richie
_____
_______________________________________________
Tutor maillist - Tutor at python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100310/1aa1a668/attachment.html>
More information about the Tutor
mailing list