Tips for debugging scripts

How can I see the output of my command to run?

Any output caused by a command to run or a script is gathered by qbee and up to 100 lines of out put is fed back into the UI through a button in the logs reports.

If you run a script with qbee or issue a "command to run" command output may be created. This output is automatically collected and made available by qbee in the log reports. Below you see the successful run of a script and its associated output. Just press on show log and all collected output is shown:

!output-script

If you don't want to see and transmit any output from the "command to run" you can alternatively pipe it to > /dev/null 2>&1 &. This effectively suppresses any output. It helps qbee to not wait for this output, but this can leave you blind while building your scripts. Therefore, a natural debugging alternative is to pipe this into log file like this

    sudo -u pi bash /path/to/my/script.sh > /path/to/output/output.log

This works very well, but even though we run the script in the "pi" user context the output will belong to root. This can be changed by using a slightly different command utilizing tee.

    sudo -u pi bash /path/to/my/script.sh | sudo -u pi tee /path/to/output/output.txt

Now the output also belongs to user "pi".

How do I produce log files with the correct user context?

Running your script in the user context as described above will cause the output written by the program to be written for that user. However, when piping to a text file the owner will be root as the process is still by qbee in the root context. A way to circumvent this issue is to use the tee command as follows:

sudo -u pi bash /path/to/my/script.sh | sudo -u pi tee /path/to/output/output.txt

whereas a simple

sudo -u pi bash /path/to/my/script.sh > /path/to/output/output.txt

will result in output.txt being written for root.