calling a .exe from Python

E

evidentemente.yo

Hi, i am trying to call a .exe from my .py file, i have found the exec
function, but i'm not sure of how to use it:S

would it be f.e.:

execl (mypath/myfile.exe,myfile,arg1,arg2,...)

????

Another question is, when i call my .exe with exec, i understand that
my .py file will stop running, and instead the new process will be
launched instead of it. Is it true?
Is there a way to launch my .exe without finishing my .py file??

thank you very much:)
 
M

MRAB

Hi, i am trying to call a .exe from my .py file, i have found the exec
function, but i'm not sure of how to use it:S

would it be f.e.:

execl (mypath/myfile.exe,myfile,arg1,arg2,...)

????

Another question is, when i call my .exe with exec, i understand that
my .py file will stop running, and instead the new process will be
launched instead of it. Is it true?
Is there a way to launch my .exe without finishing my .py file??

thank you very much:)

The exec function is for executing Python code. Have a look at the
subprocess module.
 
E

evidentemente.yo

Hey, thank you very much!!!:D

Would it matter if my .exe doesn't return any value? would it return
like an "ok" or something???

evidentemente.yo said:
 Hi, i am trying to call a .exe from my .py file, i have found the exec
 function, but i'm not sure of how to use it:S
 would it be f.e.:
 execl (mypath/myfile.exe,myfile,arg1,arg2,...)

 Another question is, when i call my .exe with exec, i understand that
 my .py file will stop running, and instead the new process will be
 launched instead of it. Is it true?
 Is there a way to launch my .exe without finishing my .py file??
 thank you very much:)

Probably what you want is this...

from subprocess import call

rc = call(["mypath/myfile.exe",arg1,arg2])

rc will contain the exit status

See the subprocess module for more things you can do
 
E

evidentemente.yo

Thank you for the help!!!:)


evidentemente.yo said:
Probably what you want is this...
from subprocess import call
rc = call(["mypath/myfile.exe",arg1,arg2])
rc will contain the exit status
See the subprocess module for more things you can do
 Hey, thank you very much!!!:D


>  Would it matter if my .exe doesn't return any value? would it return
 like an "ok" or something???

Your exe will return a value (it is part of the OS) but you can ignore
it if you want.  Just use

call(["mypath/myfile.exe",arg1,arg2])
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top