0

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?

2

1 Answer 1

2

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
Sign up to request clarification or add additional context in comments.

1 Comment

It's common for interactive programs to write to stderr instead of stdout. For example, read -p "Type something: " will display its prompt on stderr.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.