I have a program that exits automatically upon reading an EOF in a given stream ( in the following case, stdin ).
Now I want to make a shell script, which creates a named pipe and connect the program's stdin to it. Then the script writes to the pipe several times using
cat ( and other tools that automatically generates an EOF when they exit ). The problem I'm facing is, when the first
echo is done, it sends an EOF to the pipe and make the program exit. If I use something like
tail -f then I can't send an EOF when I intend to quit the program. I'm researching a balanced solution but to no avail.
I've already found both how to prevent EOFs and how to manually send an EOF but I can't combine them. Is there any hint?
#!/bin/sh mkfifo P program < P & : # Run in background # < P tail -n +1 -f | program echo some stuff > P # Prevent EOF? cat more_stuff.txt > P # Prevent EOF? send_eof > P # How can I do this? # fg