473,320 Members | 2,054 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,320 software developers and data experts.

Problem with win32pipe.popen2

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")
print stdout1.readlines() # This will print the result.
**************

test1.py:
**************
a=raw_input("a=")
print "***a=",a
print "finished!"
**************
i do not understand, why ekmain.py produces only following output:
['a=']

why is the stdin1.write("1\n") command ignored?

i tried to find an answer in this group by searching through existing
article, but i had no success.

tanks for you help!
ernst
p.s.: i working with python 2.3 on win2000.

Jan 15 '07 #1
1 1776
At Monday 15/1/2007 07:24, diego wrote:
>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")
print stdout1.readlines() # This will print the result.
**************

test1.py:
**************
a=raw_input("a=")
print "***a=",a
print "finished!"
**************
i do not understand, why ekmain.py produces only following output:
['a=']

why is the stdin1.write("1\n") command ignored?
Using popen4 instead of popen2 we get stderr too, and there is a traceback:
['a=Traceback (most recent call last):\n', ' File
"C:\\TEMP\\test1.py", line 1,
in ?\n', ' a=raw_input("a=")\n', 'EOFError: EOF when reading a line\n']

Using "python test1.py" as the popen4 argument we get the expected result:

C:\TEMP>main.py
['a=***a= 1\n', 'finished!\n']

(I don't know why)
>p.s.: i working with python 2.3 on win2000.
I used 2.4 on XPSP2.
--
Gabriel Genellina
Softlab SRL


__________________________________________________
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!
http://www.yahoo.com.ar/respuestas

Jan 16 '07 #2

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

Similar topics

2
by: Doug | last post by:
This works with a small string, but not a large one (read returns an empty string if i pass a large html file to tidy): >>> iin , iiout = popen2("tidy.exe -asxml") >>> iin.write(str) >>>...
1
by: A. Lloyd Flanagan | last post by:
OK, I've got a weird one I haven't been able to figure out yet. Admittedly I haven't had time to dig into the library source, but this behavior certainly doesn't seem right. Here's a test case: ...
1
by: Chris S. | last post by:
A wrote a small class to handle IO through pipes, but the connection only seems to work in one direction. The following code defines connection.py, engine.py, and controller.py. Once connected, the...
2
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: ...
1
by: Magnus Lycka | last post by:
I'm trying to read standard out in a process started with popen2 in a non-blocking way. (Other good ways of doing this than the one I tried are appreciated.) I've tried to dumb down my code to...
2
by: Xah Lee | last post by:
Python Doc Problem Example: os.system Xah Lee, 2005-09 today i'm trying to use Python to call shell commands. e.g. in Perl something like output=qx(ls) in Python i quickly located the...
2
by: mapik.ua | last post by:
Hi. I have such problem with os.popen2 function: //test.py file #!/usr/local/bin/python print "start" x= raw_input() print "end" //main.py file #!/usr/local/bin/python
9
by: Martin P. Hellwig | last post by:
Hi all, I was doing some popen2 tests so that I'm more comfortable using it. I wrote a little python script to help me test that (testia.py): --------------------------------- someline =...
3
by: mikem76 | last post by:
How do I automatically redirect stdout and stderr when using os.popen2 to start a long running process. If the process prints a lot of stuff to stdout it will eventually stop because it runs out...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.