Deluge execute not running filebot in bash script

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
tcl16
Posts: 4
Joined: 02 Feb 2013, 01:51

Deluge execute not running filebot in bash script

Post by tcl16 »

I am very confused. I am running deluge on linux using the deluged daemon as a service with its own user named deluge. I have it set to execute the following bash script when torrents complete using the execute deluge plugin:

Code: Select all

#!/bin/bash
TORRENT_ID=$1
TORRENT_NAME=$2
TORRENT_PATH=$3
echo "`date` $3/$2" >> /srv/deluge/deluge-pp.log
/usr/bin/filebot -script fn:amc --output "/run/mount/Data/Videos" --action hardlink --conflict skip -non-strict --def subtitles=n artwork=n backdrops=n "ut_title=$TORRENT_NAME" "seriesFormat=Shows/{n}/Season {s}/s{s}e{e} - {t}" "movieFormat=Movies/{n}" music=n plex=localhost "$TORRENT_PATH/$TORRENT_NAME" >> /srv/deluge/deluge-pp.log
echo "`date` done" >> /srv/deluge/deluge-pp.log
This script works perfectly when I run it myself. It also works when I run it as the deluge user using "sudo -u deluge sh" and then running it in that shell. However, if it is run by deluge because a torrent completed, it seems that the filebot portion of the script is skipped. Both echo messages are added to the log, but the filebot messages are not logged and the files are not linked in the output directory. Below is an example of log output when I run it as the deluged user:

Code: Select all

Wed Nov 13 20:14:23 EST 2013 /run/mount/Data/Downloads/!/Arrested.Development.S01E01.Pilot.720p.H.264.Web.DL-McXode.mkv
Parameter: subtitles = n
Parameter: artwork = n
Parameter: backdrops = n
Parameter: ut_title = Arrested.Development.S01E01.Pilot.720p.H.264.Web.DL-McXode
.mkv
Parameter: seriesFormat = Shows/{n}/Season {s}/s{s}e{e} - {t}
Parameter: movieFormat = Movies/{n}
Parameter: music = n
Parameter: plex = localhost
Argument: /run/mount/Data/Downloads/!/Arrested.Development.S01E01.Pilot.720p.H.264.Web.DL-McXode.mkv
Input: /run/mount/Data/Downloads/!/Arrested.Development.S01E01.Pilot.720p.H.264.Web.DL-McXode.mkv
Group: [tvs:Arrested Development] => [Arrested.Development.S01E01.Pilot.720p.H.264.Web.DL-McXode.mkv]
Rename episodes using [TheTVDB]
Auto-detected query: [Arrested Development]
Fetching episode data for [Arrested Development]
[HARDLINK] Rename [/run/mount/Data/Downloads/!/Arrested.Development.S01E01.Pilot.720p.H.264.Web.DL-McXode.mkv] to [/run/mount/Data/Videos/Shows/Arrested Development/Season 1/s1e1 - Pilot.mkv]
Processed 1 files
Notify Plex: localhost
Done ヾ(@⌒ー⌒@)ノ
Wed Nov 13 20:14:28 EST 2013 done
As you can see it works just as it should and the files are successfully linked. However here is an example of log output when deluge runs the script after I delete the hardlink created above:

Code: Select all

Wed Nov 13 20:22:10 EST 2013 /run/mount/Data/Downloads/!/Arrested.Development.S01E01.Pilot.720p.H.264.Web.DL-McXode.mkv
Wed Nov 13 20:22:10 EST 2013 done
Everything related to the filebot command is missing.

What makes the problem even more confusing is when I ran deluged -L debug (as deluge user) to try to figure out what is going on, deluge execute worked perfectly successfully hardlinking the files automatically. The only explanation I could come up with was that something in my bash environment is different than when deluged is run as a service, but all I could think of that that might effect is whether filebot is on my path. As you can see in my script I set it to run /usr/bin/filebot so the path should not affect anything.

The script works when run by any method other than deluged running as a service calling it when a torrent completes. What could possibly be causing the filebot command to be ignored?
tcl16
Posts: 4
Joined: 02 Feb 2013, 01:51

Re: Deluge execute not running filebot in bash script

Post by tcl16 »

I think I have now confirmed that deluge's bash is able to run filebot by using "su --shell /bin/bash --login deluge" and seeing that the filebot command still works as expected. Now I really have no idea what could be causing this issue.

Maybe I should also mention that everything I am doing is over ssh, but I don't expect that that makes a difference either.
User avatar
rednoah
The Source
Posts: 23004
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Deluge execute not running filebot in bash script

Post by rednoah »

No idea what the problem is, but >> won't help you find it. You're only redirection stdout, NOT stderr, which probably contains an error of some kind (probably filebot command not fond like you said).

@see
http://en.wikipedia.org/wiki/Standard_s ... 8stderr.29
:idea: Please read the FAQ and How to Request Help.
tcl16
Posts: 4
Joined: 02 Feb 2013, 01:51

Re: Deluge execute not running filebot in bash script

Post by tcl16 »

Thank you for the help. After redirecting stderr, I found the error: "/usr/bin/filebot: line 2: java: command not found" Apparently /usr/bin/filebot.sh which was installed by the AUR refers to java without the full path /opt/java/bin/java and this was causing the issue. I changed it from java to /opt/java/bin/java and now it is working perfectly.
Post Reply