How to debug scripts that are called by other tools?
If your script is called by another tool, you won't see any of the output. If something fails, or isn't working, the first thing is to add IO Redirection to all the calls to redirect the console output to a file.It's simple:
- Make sure your script is actually called
- Make sure to collect all the output so you can see what's going on
1.
First we make sure that our script is actually called, by adding simple debugging statements like this:
Shell: Select all
printenv > "/path/to/log.txt"
2.
Then we add IO redirection to the call that doesn't work:
Shell: Select all
filebot -script fn:sysenv > "/path/to/log.txt" 2>&1
3.
Please read the debug.sh example script.
Step-by-Step Instructions
- Download the debug.sh script:
Shell: Select all
curl -O "https://raw.githubusercontent.com/filebot/plugins/master/bash/debug.sh"
- Read the debug.sh script and try to understand what it does line by line:
Shell: Select all
cat debug.sh
- Make the debug.sh script executable for all users:
Shell: Select all
chmod +rx debug.sh
- Enter the absolute path to your /path/to/debug.sh script to execute it:
Shell: Select all
/path/to/debug.sh
- Read the console output for each test command (e.g. printenv > /tmp/printenv.txt) and confirm that each test command is working:
Shell: Select all
tail /tmp/*.txt
- Copy the absolute path to your /path/to/debug.sh script into qBT / Deluge / Transmission / etc and wait for it to be called. Then check the /tmp/*.txt text files to see what the console output (i.e. error messages) was for each test command.
The FileBot Debug Script
If the problem is difficult to pin down, then we can write our own filebot-debug.sh command, and exchange the filebot command with or own filebot-debug.sh command, that behaves exactly as if it was the filebot command by calling filebot internally, but with lots of custom debug output before and after, and redirecting all standard output and error output, so that we can see exactly how filebot is called and what filebot is doing, even if filebot itself crashes on startup or during runtime.e.g. debug qBT integration
Shell: Select all
/path/to/filebot-debug.sh @/path/to/args.txt --def "ut_label=%L" "ut_state=%S" "ut_title=%N" "ut_kind=%K" "ut_file=%F" "ut_dir=%D"