I have an application that has been working fine on Linux, but now I need to
port it to Windows XP. The program uses Popen3 to run another program. I
use Popen3 so that I can access the pid attribute, which I use to kill the
auxiliary program when necessary. Popen3 does not exist on Windows. I see
os.popen2 and os.popen3, but they provide only file objects for stdin,
stdout, and stderr so I don't see a way to kill the auxiliary program that
I start. Is there a way to do this on Windows?
--
Jeffrey Barish 2 2043
Dennis Lee Bieber wrote: On Sat, 17 Jun 2006 11:46:29 -0600, Jeffrey Barish <je*********@ea rthlink.net> declaimed the following in comp.lang.pytho n:
I start. Is there a way to do this on Windows?
There is no safe, easy, way to reliably kill a program on Windows...
Hmmm, there's one I hadn't know about... http://www.tech-recipes.com/windows_tips446.html Ah, not supplied in WinXP Home (my desktop is Pro)
Seems besides taskkill, there is also a tskill with different arguments...
The M$ response http://support.microsoft.com/default...;en-us;178893&
Granted, these don't explain how to get the PID in the first place from Python.
If possible, try using the subprocess module... It seems to have a PID attribute.
from http://docs.python.org/dev/lib/module-subprocess.html
"""
16.1 subprocess -- Subprocess management
New in version 2.4.
The subprocess module allows you to spawn new processes, connect to
their input/output/error pipes, and obtain their return codes. This
module *intends to replace* several other, older modules and functions,
such as:
os.system
os.spawn*
os.popen*
popen2.*
commands.*
"""
Jeffrey Barish wrote: I have an application that has been working fine on Linux, but now I need to port it to Windows XP. The program uses Popen3 to run another program. I use Popen3 so that I can access the pid attribute, which I use to kill the auxiliary program when necessary. Popen3 does not exist on Windows. I see os.popen2 and os.popen3, but they provide only file objects for stdin, stdout, and stderr so I don't see a way to kill the auxiliary program that I start. Is there a way to do this on Windows? -- Jeffrey Barish import subprocess x = subprocess.Pope n('nc -l 22222') x.pid
2783subprocess.P open('taskkill %s' % x.pid)
<subprocess.Pop en object at 0x0184D410> x.poll()
1 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Rajarshi Guha |
last post by:
Hi,
I have some code that runs an interactive program via popen3(). The program generates
output which is then used later on. My script looks like this:
o,i,e = os.popen3('/usr/local/adapt/bin/descmng -g')
o.write('\n%s\n\n' % (redpick))
o.close()
time.sleep(1)
|
by: Chris Green |
last post by:
Hey folks,
I'm whipping up a quick CGI to wrap a command line app and I was a bit
suprised to not find a execl-like Popen3 style object. I don't want
to bother with the shell interpreting metacharaters by constructing a
command line.
Basically, I want something that acts just like Popen3 but allows me
to specify cmd as a path + args. Does something like this exist in
the standard library? If not, it sounds like a good candidate...
|
by: |
last post by:
This could possibly be a bug, but I don't understand it fully
so I'm posting here first. Searching the list told me other
people are having this problem too.
I have created a class which inherits popen2.Popen3.
The problem is that popen2.Popen3 does not define a __del__
method to handle proper closing of the pipes or destruction of
the process. So I created one in my class:
|
by: Ruchika |
last post by:
Hi,
I want to build an embedded Visual C++ project from the python script.
This is what I do -
evc = r'"C:\Program Files\Microsoft eMbedded C++
4.0\Common\EVC\Bin\EVC.EXE"'
proj = r'"C:\Handheld\SC10\GFSDK\dev\Drivers\CE.EVC4\GFHAL\GFHAL.Vcp"'
config = "GFHAL - Win32 (WCE ARMV4) Release"
|
by: Russell E. Owen |
last post by:
I'm trying to launch an application from Python 2.3 on Windows. The
application is "ds9" (an image viewer), and is installed in C:\Program
Files\ds9\ds9
On unix I just do:
os.popen3("ds9")
and close the returned files and all is good. (I'm not trying to
communicate with the program via popen3 and so had been using
os.spawnlp, but that doesn't exist on Windows.)
| |
by: Jakob Simon-Gaarde |
last post by:
Follow-up on a thread from 1999 (see below)
Well now it is 2005 and the operating system I'm using is Windows
Server 2003, and I can still see that the same problem persists with:
win32pipe.popen2()
win32pipe.popen3()
win32pipe.popen4()
while win32pipe.popen() does almost what you want.
|
by: John |
last post by:
Hello. Can anyone tell me how to get p.poll() or a workaound to work when
using popen3() on windows? I use python 2.3. I am trying to launch a
command window to execute a command and then check periodically to see if
the command has finished executing. If it has not finished after a given
amount of time, I want to close the process. Is this possible on windows?
p = win32pipe.popen3('command') will create the tuple of files p, but none...
|
by: Pierre Rouleau |
last post by:
Hi all,
I have a consistent test case where os.popen3() hangs in Windows. The
system hangs when retrieving the lines from the child process stdout.
I know there were several reports related to os.popen3() hanging under
Windows in this group before.
I stumbled on a case where a piece of code works in some occasions and
hangs consistently given different data. It performs exactly the same
on 3 different computers running Windows:
|
by: Jonathan Mark |
last post by:
hi all...
I wrote a seemingly simple function (below) to use Popen3() and select()
to run a program and capture its exit status, stdout output, and stderr
output.
It worked fine until the box was upgraded to Debian sarge.
Now the call to select() always takes about 13 seconds before returning
the first time.
The delay only occurs when the function is running within a CGI program
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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...
| |
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,...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |