On 2007-09-07, NeoGregorian <[EMAIL PROTECTED]> wrote: > I tried instead to use: > > lines = [] > line = proc.stdout.readline() > while line : > lines.append(line) > line = proc.stdout.readline() > > This prints out everything except the ">" line, which is good. But > then freezes while waiting for input, which is bad. > > Any suggestions on how to solve this in a good way?
'readline()' reads a line, that is, some text ending with a new-line. Since your last line, the ">" prompt has no ending new-line, the call blocks, waiting for the new-line character. So the simple anser is "don't use readline()". You have to fall back to reading characters, such as "read(1)" (which block until it receives a character). In addition, you will have to do analysis on whether the line you are currently reading is a prompt, and if so, stop reading to prevent blocking. (and instead, give the program a command by writing to proc.stdin). In case you don't know, pexpect (Python expect) does all (and more) that you are trying to do. Sincerely, Albert -- http://mail.python.org/mailman/listinfo/python-list