473,794 Members | 2,729 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

win32pipe.popen 3

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.popen 2()
win32pipe.popen 3()
win32pipe.popen 4()

while win32pipe.popen () does almost what you want.
import win32pipe
win32pipe.popen ('cmd') <open file 'cmd', mode 'r' at 0x009DD698> r=win32pipe.pop en('cmd')
r.readline() 'Microsoft Windows XP [Version 5.1.2600]\n' r.readline() '(C) Copyright 1985-2001 Microsoft Corp.\n' r.readline() '\n' r.readline() 'C:\\backup\\TR Python241\\trpy thon>'

Although I think the last readline ought to return None since no
carriage return has been issued yet, it is better than popen2,popen3
and popen4, which all just block the parent process.

The current behaviour of win32pipe.popen 2(), win32pipe.popen 3() and
win32pipe.popen 4() would be acceptable for me if I knew a way to test
if there was something ready for reading, but I can't see how to do
that test, therfore I don't know when to stop reading from output :( Is
there a solution for this, can I poll/test for ready-read on popen3 I/O
objects.

Best regards
Jakob Simon-Gaarde
---------------------------
From a thread in 1999

High Arpard,

thanx for help but I got probs with that popen3 under Win95:
'o.readlines()' doesn't return anymore. To find out I checked
it line per line:

Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam import win32pipe
i,o,e=win32pipe .popen3('ver', 'b')
o.readline() '\015\012' o.readline()
'Windows 95. [Version 4.00.1111]\015\012'
o.readline() '\015\012' o.readline()


Don't know why, but it never;-) returns.
Perhaps it may be a bug in win32pipe, that it doesn't return
becourse readline couldn't find CarriageReturn/EOF?

I took win32pipe.popen ('ver','r') for a better solution.
That works fine.

greetings,
Holger

Aug 17 '05 #1
2 4171
Me again.

I forgot to mention that readline() in popen2,3 and 4 even locks up the
parent-proces though it is called from a thread, so it's a real
deadlock.

Aug 17 '05 #2
Jakob Simon-Gaarde wrote:
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.popen 2()
win32pipe.popen 3()
win32pipe.popen 4()

while win32pipe.popen () does almost what you want.


Have you tried subprocess?

Regards,
Nicolas

Aug 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
7592
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)
4
1812
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...
1
3111
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:
0
969
by: Ray S | last post by:
Does anyone know why a script that uses win32pipe.popen3() will run a script, but hang when compiled? I can't get a script that uses pipedream.py to run when compiled with McMillan or py2exe; it appears that the client process (an interactive DOS exe) returns the first screen of text, gets to its first prompt, then exits. pipedream.py does: c = os.read(self._in.fileno(), 1) and just hangs, no error. I'd appreciate any and all tips ...
13
4462
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.)
2
2042
by: Jeffrey Barish | last post by:
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...
2
2691
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:
0
1619
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
1
1803
by: diego | last post by:
I'm trying to understand how popen2 works. Found in this group, that popen2.popen2 can cause trouble so i chose win32pipe.popen2. have a look a the listing of 2 files: ekmain.py: ************** import win32pipe (stdin1, stdout1) = win32pipe.popen2("test1.py") stdin1.write("1\n")
0
9518
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,...
0
10433
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
10212
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...
0
10000
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
6777
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();...
0
5436
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
5560
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3720
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2919
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.