write eof without closing

Lars no at spam.please
Sat Aug 19 12:01:09 EDT 2006


cage wrote:
> I want to use a program that has a 'pipe' mode, in which you can use 
> stdin to send commands to the program. I found out that, when in pipe 
> mode and you are using the keyboard as input source you can do Ctrl-D to 
> 'signal' the program that you have finished typing your command. The 
> program parses and then performs the command, and it doesn't quit. It 
> quits after 'Quit\n' + Ctrl-D
> Now I want a python script to provide the input, how do i do that? I now 
> use popen to be able to write to the program's stdin (p_stdin)
> I noticed that when i do a p_stdin.close() it acts as a 'ctrl-d' in that 
> the program recognizes the signal to process the command, but then I 
> cannot use p_stdin anymore to do p_stdin.write(...)

You might want to check the pty module in the Standard Library, and/or 
Pexpect (http://pexpect.sf.net/)



More information about the Python-list mailing list