Executing a DOS program from within Python

Gary Herron gherron at islandtraining.com
Thu Mar 16 12:19:39 EST 2006


Randy Kreuziger wrote:

>This is probably a  newbie question but I need a kick start to get going.
>
>I need to run a DOS (sdetable) program from within a Python program.  I'll use command line switches so I will not need to interact with the program however it would be nice if I could capture its exit code.
>
>Thanks
>
>
>Randy Kreuziger
>(360) 902-2495  Voice
>(360) 902-2940 Fax
>ArcSDE Administrator
>Wash Dept of Fish and Wildlife
>
>
>  
>
There has been numerous ways to do this in the past (os.system, 
os.spawn, os.exec, and various operations in popen2), with os.system 
being the easiest and perhaps sufficient for your need.

However, if you are running Python 2.4, the I'd suggest the "subprocess" 
module, and in particular its convenience function "call".

Gary Herron




More information about the Python-list mailing list