By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,738 Members | 1,328 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,738 IT Pros & Developers. It's quick & easy.

calling a .exe from Python

P: n/a
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:)
Jun 27 '08 #1
Share this Question
Share on Google+
5 Replies

P: n/a
On Jun 24, 10:50*am, "evidentemente.yo" <evidentemente...@gmail.com>
wrote:
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.
Jun 27 '08 #2

P: n/a
evidentemente.yo <ev**************@gmail.comwrote:
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

--
Nick Craig-Wood <ni**@craig-wood.com-- http://www.craig-wood.com/nick
Jun 27 '08 #3

P: n/a
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???

On 24 jun, 14:32, Nick Craig-Wood <n...@craig-wood.comwrote:
evidentemente.yo <evidentemente...@gmail.comwrote:
*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

--
Nick Craig-Wood <n...@craig-wood.com--http://www.craig-wood.com/nick
Jun 27 '08 #4

P: n/a
evidentemente.yo <ev**************@gmail.comwrote:
On 24 jun, 14:32, Nick Craig-Wood <n...@craig-wood.comwrote:
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])

--
Nick Craig-Wood <ni**@craig-wood.com-- http://www.craig-wood.com/nick
Jun 27 '08 #5

P: n/a
Thank you for the help!!!:)
On 25 jun, 10:32, Nick Craig-Wood <n...@craig-wood.comwrote:
evidentemente.yo <evidentemente...@gmail.comwrote:
*On 24 jun, 14:32, Nick Craig-Wood <n...@craig-wood.comwrote:
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])

--
Nick Craig-Wood <n...@craig-wood.com--http://www.craig-wood.com/nick
Jun 27 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.