Some Python and General Helpful Linux Development Tricks:

in #linux7 years ago

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:

Sort:  

Testing my bot. Testing 1 2 3. Hope you don't mind. Nice article btw!

That's fine no problem. Thanks for upvote. What kinda bot you trying to make?

If anyone is looking to learn screen or tmux I would suggest that you try learn from videos as this is really hard to learn on your own using only text based articles.

Coin Marketplace

STEEM 0.12
TRX 0.34
JST 0.033
BTC 120463.91
ETH 4488.01
SBD 0.79