write eof without closing

cage cagedmonsterhaalditweg at gmail.com
Sat Aug 19 11:36:38 EDT 2006


Marc 'BlackJack' Rintsch schreef:
> In <ec72ev$4e0$1 at netlx020.civ.utwente.nl>, cage wrote:
> 
>> can i write a eof to a file descriptor without closing it?
>> like:
>> 	fd.write(EOF)
>> or something
> 
> What do you expect this to to?  Writing a byte to the file and you don't
> know which value this byte has?
> 
> Ciao,
> 	Marc 'BlackJack' Rintsch

ok let me explain this a bit more...
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(...)

grts,
	ruben



More information about the Python-list mailing list