2

I'm looking for a way to trick a Linux program into thinking that it is connected to TTY so that output is line-buffered instead of block-buffered.

When I call the program directly inside the terminal emulator it behaves correctly, but if I pipe its output to while read line; do ...; done or cat it doesn't.

Basically I would like to end up with something like this:

exec "${some_strange_wrapper}" "${some_program}" | while read line;
do
    # Do something...
done
ntninja
  • 1,204
  • 16
  • 20

1 Answers1

3

While considering more things to write in my question, I found the answer!

Use socat! Its an external program that can establish a lot of different kinds of connection between different types of file descriptions.

In this case however, it may be used like this:

socat EXEC:"${some_program}",pty stdout

Thanks to everybody out there, checking if this question needs answering! (Although it isn't necessary in this case anymore...) :-)

ntninja
  • 1,204
  • 16
  • 20