By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,627 Members | 1,211 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,627 IT Pros & Developers. It's quick & easy.

Problem with win32pipe.popen2

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.