Home > Blockchain >  How to get a log file with error messages while running py file via main.sh
How to get a log file with error messages while running py file via main.sh

Time:11-13

I am running a python file in a remote location from my local machine. I am putting a main.sh file in the remote dir where the python.py file is. However, I cannot find a way to handle errors in case they occur while running the python.py.

For example:

python.py:

print(a)

I want to have a log.txt file where the error message: ''a not defined in line...'' is shown.

I tried this in the main.sh:

python3 python.py> log.txt

But this only gives output in the log.txt if the py file successfully runs.

CodePudding user response:

Try python3 python.py 2> log.txt for only errors or if you want full output try python3 python.py &> log.txt

  • Related