1

This question already has an answer here:

I would like to know how can I redirect the stdout of an app to an input of an another app but still see the app1 output.

The source app is written in c, the second app is in perl. The purpose of this, that i would like to interpret the output of the C program with the perl script, and do something based on the input. The problem is if i use the ./c_app | ./perl.pl, so use the | pipe, i can only see the output of the perl script. It's like the perl would swallow the output of the C_app.

I've tried to use the tee, and found some examples, but all of them are based on redirecting the output of the source app to a file, not to an input of an other application.

The below figure illustrate the process, the got and the expected result. enter image description here

A limitation would be that I cannot modify the C app, nor the perl, so i would solve it by using linux stuffs. Is it possible to use the same terminal to see both output? I have no idea how to solve it.

Any recommendation, bash script, etc. would be appreciated.

marked as duplicate by muru, Raphael Ahrens, glenn jackman bash Jun 27 at 13:32

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

3

Thanks @steeldriver the recommendation!

The solution is:

./c_app | tee /dev/tty | perl server.pl
  • Yes, tee is a "T-shaped" pipe – glenn jackman Jun 27 at 13:31

Not the answer you're looking for? Browse other questions tagged or ask your own question.