Let's say I got two programs: program1 and program2. I want to take the output of program1, put it into input of program2, then take output of program2 and put it into input of program1 etc.
How should bash script doing this look like? I've read a lot about pipes and input/output redirection, but I'm still not sure. Is it possible to use one pipe both for input and output of program2, and another one for program2?
I've written something like this:
PIPE=$(mktemp -u)
mkfifo $PIPE
exec 3<>$PIPE
rm $PIPE
cat <&3 >&3 &
But when I want to run program1 and program2 like this:
cat <&3 | ./program1 >&3 &
cat <&3 | ./program2 >&3 &
It doesn't work. Any clues what should I do? Thank you in advance :)