Problem with win32pipe.popen2

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • diego

    #1

    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.popen 2.

    have a look a the listing of 2 files:
    ekmain.py:
    **************
    import win32pipe

    (stdin1, stdout1) = win32pipe.popen 2("test1.py")
    stdin1.write("1 \n")
    print stdout1.readlin es() # 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.

  • Gabriel Genellina

    #2
    Re: Problem with win32pipe.popen 2

    At Monday 15/1/2007 07:24, diego wrote:
    >I'm trying to understand how popen2 works. Found in this group, that
    >popen2.popen 2 can cause trouble so i chose win32pipe.popen 2.
    >
    >have a look a the listing of 2 files:
    >ekmain.py:
    >************ **
    >import win32pipe
    >
    >(stdin1, stdout1) = win32pipe.popen 2("test1.py")
    >stdin1.write(" 1\n")
    >print stdout1.readlin es() # 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\\test 1.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!


    Comment

    Working...