> Yes, call flush() each time you're done writing.

No, it would be too easy & simple.
While stdin is NOT CLOSED stdout has not EOF, but readlines()
waits for its appearence ... and so freezes for good. IMO.
Should be like this:

import popen2
o=popen2.popen2('osql -E -S(local) -dpubs -c"GO" -n -w8000')
while 1:
    o[1].write(raw_input()+'\nGO\n')
    o[1].flush() # this line can be commented
    res=''
    while 1:
        line=o[0].readline()
        if line=='\n': # ??????????????????????????????
            break
        res+=line
    print res

How to break the while loop?
What is the sign of "there is left nothing to read"?

2.
I'm still curious why multiline parameter does not work in Py.
This is how it looks in VBS (and works Ok):

Set w = CreateObject("WScript.Shell")
q = "select * from authors" & vbCrLf
q = q + "select getdate()" & vbCrLf
q = q + "select * from jobs"
Set e = w.Exec("osql.exe -Q""" + q + """")

In shell line it looks like:
osql.exe <...> -Q"select * from bla"
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to