bidirectional pipes in shell

The other day I wanted to control one interactive command line program from another. So the controlling program A had to have it’s output connected to program B’s input (normal pipe) and program B output had to be connected back to program A input (the tricky part).
After trying different things I found the easiest approach to be with named pipes:

rm -f app_fifo && mkfifo app_fifo && cat app_fifo | ./app_controller | ./myapp > app_fifo && rm -f app_fifo

In ksh shell there seems to be easier built in way for doing this kind of thing, but I have never used it.

Leave a Reply

Your email address will not be published.


*