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

Capture and play voice with Asterisk ARI -

c++ - Can not find the "fiostream.h" file -

visual studio - Installing Packages through Nuget - "Central Directory corrupt" -