Bash脚本的行为取决于执行它的方式

时间:2013-12-15 13:10:35

标签: bash shell utorrent

我有一个bash脚本,作为utorrent-server的后处理脚本,将变量传递给名为FileBot的媒体。

脚本:

#!/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

如果我手动运行此脚本,它会按预期工作,但是当uTorrent执行它时,它会返回“No such file or directory”。通过stderr。我最初让uTorrent直接调用这个脚本,但是我遇到了同样的问题。

有谁知道可能导致这种情况的原因?

UPDATE(所有目录/文件夹的权限):

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 个答案:

答案 0 :(得分:2)

更改当前工作目录。

答案 1 :(得分:1)

如果filebot.sh是no-such-file,我建议你试试这个:

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

如果是你的run.sh,

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

您可以尝试将filebot.sh作为所有者运行。我觉得值得一试。

    chown YOURUSERNAME /usr/share/filebot/bin/filebot.sh
    chmod u+s /usr/share/filebot/bin/filebot.sh
相关问题