Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to run a dos executable from python

180 views
Skip to first unread message

lblr33

unread,
Jan 26, 2006, 3:46:03 PM1/26/06
to pytho...@python.org
I have an executable (e.g. myprog.exe) which takes some set number of
arguments.

This command works ok:
os.system(r"c:\tmp\myprog.exe arg1 arg2 arg3")

The problem is that the path to the program and the arguments are
variable at runtime so I need to pass them as arguments.

Thanks


Fredrik Lundh

unread,
Jan 26, 2006, 3:59:19 PM1/26/06
to pytho...@python.org
"lblr33" wrote:

the tutorial explains how to piece together strings:

http://docs.python.org/tut/node5.html#SECTION005120000000000000000
http://docs.python.org/tut/node9.html#SECTION009100000000000000000

alternatively, you could use the subprocess module instead of os.system,
and pass

http://docs.python.org/lib/module-subprocess.html

retcode = subprocess.call(["c:/tmp/mycmd.exe", arg1, arg2, arg3])

</F>

Larry Bates

unread,
Jan 26, 2006, 4:12:55 PM1/26/06
to
Take a look at the subprocess module or on older versions of Python
you can use os.spawn.

Larry Bates

0 new messages