AprilGrimoire
AprilGrimoire

Reputation: 111

How to redirect A's stdout to B's stdin and B's stdout to A's stdin?

Now I have programs A and B. I want to redirect A's stdout to B's stdin, and B's stdout to A's stdin using bash.

I saw someone doing this, but they didn't explain how they did it.

Any suggestions?


Upd: I found a script which can accomplish this task, but I don't understand why:

{ ./A < /dev/fd/3 | ./B 3>&-; } 3>&1 | :

Upvotes: 1

Views: 240

Answers (1)

that other guy
that other guy

Reputation: 123600

You can use the socat utility. It'll connect anything to anything else, including two processes to each other:

socat exec:'A' exec:'B'

Upvotes: 2

Related Questions