Uroboros
Uroboros

Reputation: 189

Python output redirecting

When I'm running python3 interpreter on Linux machine and trying to redirect it's stdout to file like this, nothing happens:

user@workmachine:~$ python3 > python.txt
Python 3.5.2 (default, Nov 23 2017, 16:37:01) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
\>>>

File python.txt remains empty while interpreter is running as well as after it was closed. All it's output is still in terminal.

On the other hand, if I'm redirecting R interpreter the same way ( R > R.txt ) the result is as expected ( all output redirected to file, see nothing in terminal ).

What's the difference? Are python writes all it's output to another stream than stdout, or what?

Upvotes: 0

Views: 116

Answers (1)

Romeo Ninov
Romeo Ninov

Reputation: 7225

For your case seems python send information to STDERR and not to STDOUT. So you should use redirect like:

user@workmachine:~$ python3 2> python.txt

Upvotes: 2

Related Questions