469,327 Members | 1,265 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,327 developers. It's quick & easy.

execute commands independantly

Hi,

I am trying to execute an executable or a pyton script inside my
program. I looked at the subprocess and os module. But all the
functions in these modules blocks my application. What I want to do is
run the subprocess without any concern. I don't care of its return type
or child signals. Just start and let it run independantly.

Thanks,
Mike

Sep 6 '05 #1
5 1175
Mike Tammerman wrote:
Hi,

I am trying to execute an executable or a pyton script inside my
program. I looked at the subprocess and os module. But all the
functions in these modules blocks my application.


subprocess doesn't block unless you call .wait():

from subprocess import Popen
proc = Popen('sleep 2; echo "Hello, world!"', shell=True)
print "In two seconds, something will happen."
proc.wait()
print "Did you see that?"
Sep 6 '05 #2

Mike Tammerman wrote:
I am trying to execute an executable or a pyton script inside my
program. I looked at the subprocess and os module. But all the
functions in these modules blocks my application. What I want to do is
run the subprocess without any concern. I don't care of its return type
or child signals. Just start and let it run independantly.


If you don't need any output, os.system('app') should do.

Sep 6 '05 #3

If you want it to return when the program is finished then use
os.system('app') but if you just want to start it and return right
away, use os.startfile('app')

Sep 6 '05 #4
You're right,

I tried subprocess.call and os.spawn* functions. Popen is what I will
be happy with.

Thanks a lot.

Mike

Sep 6 '05 #5
On 6 Sep 2005 08:07:12 -0700, Eric McGraw <th************@gmail.com> wrote:

If you want it to return when the program is finished then use
os.system('app') but if you just want to start it and return right
away, use os.startfile('app')


That one is Windows-only, though -- at least in 2.3 where I live. The
os.spawn* family of calls are more portable, but I'm not sure it's a good
idea to just spawn-and-forget a process.

/Jorgen

--
// Jorgen Grahn <jgrahn@ Ph'nglui mglw'nafh Cthulhu
\X/ algonet.se> R'lyeh wgah'nagl fhtagn!
Sep 6 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by news.microsoft.com | last post: by
15 posts views Thread by Madhanmohan S | last post: by
4 posts views Thread by Chr1s | last post: by
15 posts views Thread by tmp123 | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Purva khokhar | last post: by
reply views Thread by haryvincent176 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.