473,608 Members | 2,083 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1259
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('a pp')

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('a pp')


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

Similar topics

3
5181
by: Lance | last post by:
Hi All, I would like to read commands from a file and execute them in VB, something like reading str = "hello world" into VB and execute it. Any suggestions will be appreciated. Thanks, Lance
2
18062
by: news.microsoft.com | last post by:
Good morning everybody, How can I use WScript.Shell to execute Ms-DOS commands and can I see the outputs commands in the asp page? In the past, using Win. NT 4 Server and cmd..shell attribute to a variable I could write the results in the screen page. Any sample?
15
14046
by: Madhanmohan S | last post by:
Hi All, I want to run a command line appplication from C#. When i start the application, it will go into specific mode. After that, i have to give commands to use the application. How Can This Be Done in C#.... Thanks and Regards, S.Madhanmohan
6
2331
by: zoltix | last post by:
Hi, I would like to access to execute specific commands but the privileges are not enough from an aspx Page. Because this service run as IU_IISSERVER, therefore aspx hasn’t access to these resources and it is normal.. But sometimes, I need these privileges for special commands. How to execute some “lines code” for other user than currently logged user? Thank you for your help
4
3966
by: Chr1s | last post by:
How do I execute a crontab command using php (not CLI) as user Joe? I don't have any problem getting output from commands such as 'ls' using passthru and exec but I am stumped with crontab. Many thanks! Chris
15
2801
by: tmp123 | last post by:
Hello, Thanks for your time. We have very big files with python commands (more or less, 500000 commands each file). It is possible to execute them command by command, like if the commands was typed one after the other in a interactive session?
2
1384
by: sajalsajal | last post by:
how can i read and execute VB6 commands from a text file (like INI file) like a VBScript but not actually a vbscript. evaluate commands from a text file
1
3549
by: raocheng | last post by:
Please see the following code. Suppose I have many shell commands to be executed. And I don't want to fork a sub shell for each command(eg: status,output = commands.getstatusoutput(cmd)) because it is too expensive. I want to use only one sub shell to execute all these commands and want to get each command's output. How can I accomplish this task ? Thanks in advance. =========================================== #!/usr/bin/env python
2
5613
by: rcook349 | last post by:
I'm trying to automate our builds and publishes of our Windows application (deployed to a website via ClickOnce). I'm getting close, I think, on the commands I need to execute. However, how do I put these commands in some sort of executable file? I thought at first a VBScript file (Windows script), but from what I'm reading that is old techology. A script in PowerShell? Not too familiar with this?
0
8063
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8498
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8478
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8152
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8341
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6817
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
3962
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4025
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1331
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.