473,387 Members | 1,579 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

calling a .exe from Python

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
5 2753
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Natsu Mizutani | last post by:
Hello, I'm trying to wrap a c++ library using MPI inside with boost.python (or SWIG). I managed to find that calling `MPI::Init()` embeded in a c++ funtion would not work. So, I decided to use...
1
by: Stephen Kellett | last post by:
Hello everyone, I'm trying to do something in C calling Python and its failing. I'd be grateful if you could take a look and hopefully you have an answer. What I'm trying to do is determine...
10
by: Finger.Octopus | last post by:
Hello, I have been trying to call the super constructor from my derived class but its not working as expected. See the code: class HTMLMain: def __init__(self): self.text = "<HTML><BODY>";...
47
by: teju | last post by:
hi, i am trying 2 merge 2 projects into one project.One project is using c language and the other one is using c++ code. both are working very fine independently.But now i need to merge both...
16
by: Jaco Naude | last post by:
Hi there, This is my first post over here and I hope someone can give me some guidance. I'm trying to embed Python into a Visual C++ 2008 application and I'm getting linker problems. I've...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.