Let's say I have a python script called service.py running as a kind of daemon in the background, and I want to give it some information by piping text into its stdin:
> pgrep -f service.py
[pid of process]
> echo -e 'test\n' > /proc/[pid of process]/fd/0
My python script should take whatever is in its stdin and assign it to a variable inp:
import sys
while True:
inp = sys.stdin.readline()
#do something with inp
But when i do the above, it just prints the stdin stream:
> python service.py
test
The effect is the same if I literally just have this in my script
import sys
inp = sys.stdin.readline() #sys.stdin.readline() never returns
#script never exits
What am I doing wrong?