Bash script acts differently depending on what executes it

958 views Asked by At

I have a bash script which acts as a post-process script for utorrent-server that passes on variables to a media renamed called FileBot.

Script:

#!/bin/bash
TORRENT_NAME=$1
TORRENT_PATH=$2
TORRENT_LABEL=$3
TORRENT_KIND=$4
TORRENT_TITLE=$5

/usr/share/filebot/bin/filebot.sh -script fn:amc --output "/mnt/Storage/" \
   --log-file "amc.log" --action move --conflict override -non-strict \
   --def music=n subtitles=en artwork=n xbmc="192.168.0.123" deleteAfterExtract=y \
     clean=y "ut_dir=$TORRENT_PATH" "ut_file=$TORRENT_NAME" "ut_kind=$TORRENT_KIND" \
    "ut_title=$TORRENT_TITLE" "ut_label=$TORRENT_LABEL" "ut_state=5" "seriesFormat=TV \
    Shows/{n}/Season {s.pad(2)}/{n} - {s00e00} - {t}" "movieFormat=Movies/{n} ({y})/{n} ({y})" \
 &>> /home/xbmc/run.log

If i run this script manually, it works as intended, however when uTorrent executes it, it returns "No such file or directory." via stderr. I originally had uTorrent calling this script directly however I was having the same issue.

Does anyone know what could cause this?

UPDATE (Permissions for all directories/folders):

drwxr-xr-x   3 root root 4096 Nov 27 23:52 /home  
drwxr-xr-x  20 xbmc xbmc 4096 Dec 15 21:46 /home/xbmc  
drwxr-xr-x  10 root root 4096 Oct 17 06:51 /usr  
drwxr-xr-x 218 root root 4096 Dec 13 15:32 /usr/share  
drwxr-xr-x   3 root root 4096 Dec 15 15:55 /usr/share/filebot  
drwxr-xr-x   2 root root 4096 Dec 15 18:56 /usr/share/filebot/bin  
-rwxr-xr-x 1 xbmc xbmc 615 Dec 15 21:44 /home/xbmc/run.sh  
-rwxr-xr-x 1 root root 552 Dec 15 18:56 /usr/share/filebot/bin/filebot.sh  
2

There are 2 answers

6
Ed Heal On

Change the current working directory.

9
manolo On

IF filebot.sh is the no-such-file, I suggest you to try with this:

    chmod -R a+x /usr/share/filebot/bin/filebot.sh

IF it is your run.sh,

    chmod -R a+x /home/xbmc/run.sh

You can try running filebot.sh as the owner. I think it worths a shot.

    chown YOURUSERNAME /usr/share/filebot/bin/filebot.sh
    chmod u+s /usr/share/filebot/bin/filebot.sh