I’m having a helluva time debugging a python app I’ve written for an embedded raspberry pi project I’m working on because it’s using a TFT screen instead of a full monitor and has no monitor/keyboard, so i’m having to launch the python app via an icon on the TFT desktop (very small). I can’t launch the app via SSH because it requires X (due to PyQT4), so to get it running on the RPi, it has to be launched using the desktop icon on the device itself.
The desktop icon launches a shell script that uses the following:
sudo python appname.py >> logfile.log
but that doesn’t write whatever error it’s hitting, it only logs whatever I’m doing prior to any error.
If I remove the SD card from the RPi and put it into a 2nd RPi I have connected to a full mouse/keyboard/display, I can run the python app and see the error in the terminal, but that doesn’t help me figure out what’s happening on the fully assembled device.
How do I log the error that I would normally see in the terminal?
EDIT: Of course I’m doing error catching in the app, but I’m sending shell commands in the python app that could be the problem that wouldn’t be caught by a try/catch in python. I’d like to catch ALL of the output in the terminal when you launch a python script regardless of it’s source.
Advertisement
Answer
As it stands you’re just capturing stdout. Modify your invocation to the following:
sudo python appname.py >> logfile.log 2>&1
This will redirect both stdout and stderr.