0

When I run my python script (content irrelevant for this question, just uses print a couple of times) interactively, it sends the output straight away.

When I use it in a pipe to tee or in an output redirection (./script.py > script.log) there is no output. What am I doing wrong?

Bert Peters
  • 1,505
  • 13
  • 30

2 Answers2

1

I suspect you're encountering output buffering, where it's waiting to get a certain number of bytes before it flushes. You can look at the unbuffer command if that is undesirable for you.

Eric Renouf
  • 13,950
  • 3
  • 45
  • 67
0

As it turns out, Python detects whether or not you are using a tty, and increases its buffering when you are not. Several options on how to disable this can be viewed at this question.

Bert Peters
  • 1,505
  • 13
  • 30