Transmission script-done script not working, help appreciated

windyboi

Explorer
Joined
Jan 7, 2016
Messages
79
#! /bin/bash
# IF torrent contains music (torrent folder is in /mnt/music) then
#copy it to the afp share /mnt/newmusic

parentdir="$(dirname "$TR_TORRENT_DIR")"
if [ $parentdir="/mnt/music/" ]
then
cp $TR_TORRENT_DIR /mnt/newmusic
fi


This script isn't working, it's my first ever bash script I've written but I think it's pretty simple and should work.. any one able to see any glaring errors?

permissions on the script are 777

Thank you
 

windyboi

Explorer
Joined
Jan 7, 2016
Messages
79
Actually I found an error in the shebang line, it wasn't liking bash for some reason (even though I had installed bash in the jail) so I changed it to /bin/sh. When I run the script from the command line the output is :

[root@transmission_1 /scripts]# ./torrentDone.sh
usage: cp [-R [-H | -L | -P]] [-f | -i | -n] [-alpvx] source_file target_file
cp [-R [-H | -L | -P]] [-f | -i | -n] [-alpvx] source_file ... target_directory

But I don't expect anything more than that, because it doesn't understand the environment variable when I am running it this way.
 
D

dlavigne

Guest
Yeah, when you install bash in a jail, it is considered a third party app so it is installed to /usr/local/bin/bash (use which bash to get the path). Does that fix your script?
 

windyboi

Explorer
Joined
Jan 7, 2016
Messages
79
Ahh ok thanks. Nop, still not working :( . The script seems so simple, and I've chmoded it as 777, and I've set the script up in transmission settings for script torrent done. Is there any log that I can look at where errors may go?

Thank you
 
D

dlavigne

Guest
Does it display any errors when you run the script or does it just silently fail? Any errors should be displayed on the screen when the script is run.
 

windyboi

Explorer
Joined
Jan 7, 2016
Messages
79
well, if I run the script from the cli manually, the output is:
[root@transmission_1 /scripts]# ./torrentDone.sh
usage: cp [-R [-H | -L | -P]] [-f | -i | -n] [-alpvx] source_file target_file
cp [-R [-H | -L | -P]] [-f | -i | -n] [-alpvx] source_file ... target_directory

But, when the script is running properly, I do not see the script output, how do I see it? I have put the path to the script in the "Script torrent done" box in the Transmission settings in FreeNAS.

Thanks
 
D

dlavigne

Guest
There won't be any output if the cp command works correctly.
 

windyboi

Explorer
Joined
Jan 7, 2016
Messages
79
There won't be any output if the cp command works correctly.

But it is of course not working correctly if I run the script manually, because $TR_TORRENT_DIR isn't valid.

I thought that this is an environment variable of the torrent directory, which will be passed to the script when the script is called from transmission.

There doesn't seem to be anything wrong with the cp command cp $TR_TORRENT_DIR /mnt/newmusic
 

windyboi

Explorer
Joined
Jan 7, 2016
Messages
79
Right so I've just discovered that this functionality isn't even working.

In the GUI for transmission settings, under "Script torrent done" I've got /scripts/test.sh

test.sh is executable by all and contains:

#!/usr/local/bin/sh
echo "test" >> /scripts/test.txt

But, upon completion of a torrent, the script does NOT have the desired effect.

Any one know why this may be?

/scripts is also writeable by all (777 permission)

both the test.sh file and the directory are owned by the transmission user
 
Last edited:
Top