Question: How to execute an EXE with Python?

Fausto Arinos de A. Barbuto fbarbuto at telusplanet.net
Tue Aug 27 08:47:02 CEST 2002


  
Hi Peter,

    Thanks for the tip, but it did not work. Sorry. :-(

    I am trying to run an executable whose source code was
    written in C. All it does is to open a file, write integers
    from 0 to 100 into this output file, close it and exit. A very
    simple and prosaic test.

    Nonetheless, I get a "0" (zero) as exit status when I execute
    the command you suggested. That means, as fas as I know,
    that the execution had been well-succeeded. But I cannot find
    the output file anywhere on the hard disk, however. What the
    problem might be?

    Thanks once again for your help.

---Fausto 


Peter Hansen <peter at engcorp.com> wrote:
> "Fausto Arinos de A. Barbuto" wrote:
>> 
>> 
>> Hi everybody,
>> 
>>     I need to write a Python script to call and execute a DOS
>>     .EXE application. How do I do that? I know that there is
>>     os.execv(path, args) and similars, but can't get the right
>>     syntax. Suppose I have a C:/Progs/MyProg.EXE binary
>>     that I want to execute. What would then be the correct
>>     command?
> 
> import os
> os.system('c:/progs/myprog.exe')
> 
> might do the trick.
> 
> -Peter




More information about the Python-list mailing list