This content was muted by moderators for not following community guidelines.

Some Python and General Helpful Linux Development Tricks:

Words
158
Reading
1 min
8y
Listen to this post
~1 min

Some Python and General Helpful Linux Development Tricks:

Redirect stderr and stdout to two different files and view the output seperately:

First stdout on its own:

If you run your python app then do the following:


virtenv) $ python3 try.py > out.txt

Then in another terminal do the following while that is running:

(Make sure to run in same directory:)


$  tail -f out.txt

Stderr on its own:


virtenv) $ python3 try.py 2> error-out.txt

Then in another terminal do the following while that is running:

(Make sure to run in same directory:)


$  tail -f out.txt

Now you can combine the two like this:


virtenv) $ python3 try.py  > out.txt 2> error-out.txt

Then in another window run:


$ tail -f error-out.txt

And in another window run:


$ tail -f out.txt

If you read this and you are not familiar with screen or tmux, then you will be thinking, how do I do this in the same terminal?
You should have a look at screen or tmux, they are used to open multiple terminal sessions in one window and to switch between them.
You can read more about them here:

Tmux:

Screen:

Some Python and General Helpful Linux Development Tricks: | Ecency