I want to output some data to a pipe and have the other process do something to the data line by line. Here is a toy example:
mkfifo pipe
cat pipe&
cat &
Put all the statements you want to output to the fifo in the same subshell:
# Create pipe and start reader.
mkfifo pipe
cat pipe &
# Write to pipe.
(
echo one
echo two
) >pipe
If you have some more complexity, you can open the pipe for writing:
# Create pipe and start reader.
mkfifo pipe
cat pipe &
# Open pipe for writing.
exec 3>pipe
echo one >&3
echo two >&3
# Close pipe.
exec 3>&-