Executing a DOS program from within Python
iapain
iapain at gmail.com
Thu Mar 16 14:10:24 EST 2006
Use os.system and if you wanna get rid of console window use subprocess
as gary said, you could have better options like killing proc if it
hang/stuck using win32api (if you are using windows) else process
timeout.
ret = os.system('sample.exe') # ret will have return code and os.system
execute sample.exe
#using subprocess
import subprocess
process = subprocess.Popen('sample.exe', stdout=subprocess.PIPE)
#you can print error/output using stderr/stdout pipe
Both are easy to implement!
Thanks!!
More information about the Python-list
mailing list