Problem with win32pipe.popen2

D

diego

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.
 
G

Gabriel Genellina

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top