How to run a dos executable from python

Fredrik Lundh fredrik at pythonware.com
Thu Jan 26 21:59:19 CET 2006


"lblr33" wrote:

> 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.

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>






More information about the Python-list mailing list