Script issue

Ask for help and report issues not specific to either the Mac OS X or GTK+ versions of Transmission
Post Reply
goodknight
Posts: 4
Joined: Sun Feb 26, 2012 11:21 am

Script issue

Post by goodknight »

I'm new to scripting, and I've tried to write a simple command script that would let me add the first torrent file from a given directory. I'm strapped for bandwidth so I can only download a single torrent at a time. I delete the .torrent file upon download start (with no options dialog) and call a script when completed. The script is:

Code: Select all

cd ~/Downloads
transmission $(ls -1 *.torrent | head -1)
I can run the script from the shell with:

Code: Select all

sh <script name>
And it runs fine, adding a torrent from the ~/Download directory, even when a transmission session is already open.
But I cannot get transmission to run the script when a download completes.
What am I forgetting/missing?
gunzip
Posts: 272
Joined: Wed May 05, 2010 2:12 am

Re: Script issue

Post by gunzip »

maybe try something like this..

Code: Select all

#!/bin/bash
cd ~/Downloads
transmission-remote --add "$(ls -1 *.torrent | head -n1)"
then make sure script has execute permissions..

$ chmod +x ./script-name

i believe you need to use transmission-remote (not transmission) to have this work as a background script.
rb07
Posts: 1400
Joined: Sun Aug 24, 2008 3:14 am

Re: Script issue

Post by rb07 »

goodknight wrote:I'm strapped for bandwidth so I can only download a single torrent at a time
If you are using a recent version then you don't need a script for that, the download queue functionality does handle limiting how many torrents are downloaded, and queuing all the rest.

It looks like transmission-remote doesn't have an option to set the queue limits. Then the only option is to use one of the GUI clients with remote session capability (Transmission-Qt, Transmission-Mac?, perhaps others including 3rd party).

Hold on, another option is to edit settings.json, which has these lines:

Code: Select all

    "download-queue-enabled": true, 
    "download-queue-size": 3, 
...
    "queue-stalled-enabled": true, 
    "queue-stalled-minutes": 30, 
...
    "seed-queue-enabled": false, 
    "seed-queue-size": 10, 
Note: Queuing still has a bug or not completed feature: if you stop the daemon the queued torrents are not saved as queued but paused. And the lack of options in transmission-remote looks like another task to complete the queue feature. And the "seed queue" can only be set in settings.json (I've never tested it, so I don't know if it works).
goodknight
Posts: 4
Joined: Sun Feb 26, 2012 11:21 am

Re: Script issue

Post by goodknight »

Thanks for the help. I add the line

Code: Select all

#!/bin/bash
to the head of the script. And I changed the execute permissions on the script, which I hadn't done before. For some reason though transmission is still not running the script. I haven't got a transmission-remote package installed on my system, which is strange given that the man page for transmission seems to mention it in 'See Also.'
the download queue functionality does handle limiting how many torrents are downloaded, and queuing all the rest.
I may be overlooking something or may have a different kind of transmission GUI than what's normal (?, I've got the one that came with Debian 6), but I couldn't find queuing handling in the Preferences. I have yet to set up the remote session capability and haven't seen the features for that yet (I installed the app...next step would be to test it.).

I'm guessing that I should use a different GUI? From some of your descriptions it seems that there are more feature-rich versions than the one that I'm using.

Or, when transmission's preferences say "script," as in "Call script when torrent is completed," do they mean any kind of script? I'm using bash, do they mean another kind? I don't know...this is weird.
gunzip
Posts: 272
Joined: Wed May 05, 2010 2:12 am

Re: Script issue

Post by gunzip »

goodknight wrote:.. I've got the one that came with Debian 6 ..
if Debian 6 (squeeze), most likely you are running Transmission GTK v2.03 if you did 'apt-get install' method. The script-done feature was first introduced in v2.00, but then only for the daemon. It wasn't till version 2.20 that all platforms became supported.

Same deal with queuing, that wasn't introduced until v2.40 . Your version is pretty dated at this point .. btw the current release is 2.50.

https://trac.transmissionbt.com/wiki/Changes
goodknight
Posts: 4
Joined: Sun Feb 26, 2012 11:21 am

Re: Script issue

Post by goodknight »

if Debian 6 (squeeze), most likely you are running Transmission GTK v2.03
You are correct.

Code: Select all

dpkg -l transmission
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                   Version                                Description
+++-======================================-======================================-============================================================================================
ii  transmission                           2.03-2                                 lightweight BitTorrent client
I see that there are newer versions available on the other Debian types (wheezy) and (sid). I guess I'd better not try to install those versions because the dependencies are different (or some other underlying differences). Thought about building it from source, but I seriously doubt I could get it to work faster than the distro people working on Deb. I'll just have to keep tinkering with my script. I have no new ideas on changing it's syntax to make it work..:

Code: Select all

#!/bin/bash
cd /home/wolf/Downloads
transmission $(ls -1 *.torrent | head -1)
The only thing I can think of is that there may be a bug in 2.03-2 (?) or I'm using the wrong kind of script or there's just something wrong with my syntax. It may just come down to me having to wait until I get enough understanding to fix it. (A directed study though..)
gunzip
Posts: 272
Joined: Wed May 05, 2010 2:12 am

Re: Script issue

Post by gunzip »

goodknight wrote:The only thing I can think of is that there may be a bug in 2.03-2 (?) or I'm using the wrong kind of script or there's just something wrong with my syntax. It may just come down to me having to wait until I get enough understanding to fix it. (A directed study though..)
as mentioned in my previous comment, transmission GTK v2.03 does not support the script-done feature .. just the transmission-daemon.
goodknight
Posts: 4
Joined: Sun Feb 26, 2012 11:21 am

Re: Script issue

Post by goodknight »

as mentioned in my previous comment
Ooo, right. You did say that. I guess I didn't catch what you meant because the menu item is there in 2.03. Sorry!
Post Reply