You can run external programs on torrent completions. Find the setting under Options > Downloads
If you're writing a bash script, make sure you make the script executable by using chmod 755 /path/to/script
chmod 755 /path/to/script