In a shell script, I want to write to the stdin of an external process X using a named pipe, and I want to send the stdout/stderr from another named pipe to the current terminal.
The external process X is receiving stdin via PIPEIN and it's sending it's stdout/stderr to PIPEOUT.
tail -f $(tail -F PIPEOUT) & # (1) this is completely wrong, need help here
for i; do
echo "${i}" > PIPEIN # send stdin to X
done
echo "[stdin end]" > PIPEIN # signal that we are done writing (there might be a better way lol)
So in the above script, we have already started process X, it's been running for some time. But now, when we run the above script we want to send X some stdin and we want to read in the stdout from process X, using PIPEOUT.
What I am trying to do above is set-up a read on PIPEOUT before sending stdin to X, to make sure I capture all of the stdout/stderr of X. The problem is that I don't know how to run some background process (tail or cat to read from PIPEOUT) and send that stdio to the current terminal.
Does anyone know what I am talking about. If I am not mistaken, I just need to fix line labeled (1) and somehow setup a read in the background that can read from PIPEOUT and send that stdio to the current terminal/tty somehow.