SSH output isn't line buffered?

Use ssh -t ... to force a pseudo-tty allocation (which is what you get when you log in normally via ssh.)


To expand a little bit on Ryan Fox's answer: Many programs (most? - it's the default for any C program) line-buffer stdout when they're talking to a terminal, but fully buffer it otherwise. (The C standard specifies that stdout is initially fully buffered when it "can be determined not to refer to an interactive device".)

So what you're seeing is that the output of the program you're running remotely (as given to stdout) isn't line-buffered; ssh is just passing through what it gets when it gets it. (I think ssh actually does no buffering at all on its output - that would be the least magical way to make sure that the user sees what the remote program intended.)


To expand even more on Ryan Fox's answer, ssh -t didn't work for me either, but ssh -tt did. See the ssh man page about -t:

Multiple -t options force tty allocation, even if ssh has no local tty

Tags:

Ssh