New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
Help with a script
Hi:
I have to run a comand, for example:
python2.7 /dir/modulo.py
modulo.py has an error (it doesnt matter what kind of error)
The output is:
Starting script...
File " /dir/modulo.py", line 77, in
main(config)
File " /dir/modulo.py", line 62, in main
rows = motorMySQL.getPortalDax(config)
NameError: global name 'motorMySQL' is not defined
I want to save the error in a file, problem is I don't know how to do it.
I tried with:
python2.7 /dir/modulo.py > error.log
But it just save: "Starting script..." and not the error.
Thanks guys.
Comments
i think you can log the output of "screen"
What do you mean ?
That you should be able to run the command in a "screen" and log the entire output to a file
did you try python2.7 -u test.py > output.txt
Better to use the standard logging module https://docs.python.org/2/library/logging.html
It jsut save a message generate by the code but it doesn't save the error output.
python2.7 -u test.py &> output
Try this you need to redirect stderr too:
python2.7 /dir/modulo.py > output.log 2>&1
How could I forget that part with "&" :P
Thank you all @definedcode @vfuse @4n0nx