python - How to send keyboard input(strokes) to background process in Linux? -


i have started python script in terminal (this terminal has been closed) , sent background. program expects input keyboard , keeps waiting. how send input, 'y\n'(letter 'y' followed enter) program? assume pid 1234.

i have tested method not work.

echo 'y\n' | /proc/1234/fd/0 , echo 'y\n' > /proc/1234/fd/0

update: relevant part of python script :

ans = raw_input('overwrite?(y/n):') if ans == 'y':     do_something() else:     do_otherthing() 

try this:

echo -ne 'y\n' > /proc/1234/fd/0 

an alternative use command yes. more information use man yes.

yes > /proc/1234/fd/0 

Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -