Pages

14 November 2012

Control a remote linux Transmission client.

This is more or less a follow-up to my previous post about connecting to a remote linux desktop session: http://sakiwinet.blogspot.com/2012/11/connect-to-remote-linux-systems-x.html

Here I will show how you can control a remote Transmission torrent client from the command line. Transmission is the standard Ubuntu torrent client. This will mean that instead of following my previous post to download the latest Linux Mint or Ubuntu torrent, you could add it via the command line from a remote ssh session.

In order for this to work you will need to ensure that Transmission has it's "web client" enabled as shown in this screenshot. For security reasons you would not want to open it to the world, so make sure that it is only open to the local machine that it is running on (i.e. 127.0.0.1)

You will also need to install the "transmission-cli" package, using whatever package manager your system uses, in Ubuntu you can do "sudo apt-get install transmission-cli", and make sure Transmission is running, if it isn't then you can start it from the command line as follows:
  1. clive@dogmatix > transmission-remote -l
  2. [12:08:22.988] transmission-remote: (http://localhost:9091/transmission/rpc/) Couldn't connect to server
  3. clive@dogmatix > export DISPLAY=:0
  4. clive@dogmatix > nohup transmission-gtk >/dev/null 2>&1 &
  5. [1] 22245
  6. clive@dogmatix > transmission-remote -l    
  7. ID     Done       Have   ETA           Up    Down  Ratio  Status       Name
  8.    1    100%     801 MB  Done         0.0     0.0   0.00  Stopped      linuxmint-13-cinnamon-dvd-64bit-rc.iso
  9. Sum:             801 MB               0.0     0.0
  10. clive@dogmatix >


To add a torrent to Transmission you would do the following (You need to know the url for the torrent file itself)
  1. clive@dogmatix > transmission-remote -a "http://torrents.linuxmint.com/torrents/linuxmint-14-cinnamon-dvd-64bit-rc.iso.torrent"
  2. localhost:9091/transmission/rpc/ responded: "success"
  3. clive@dogmatix > transmission-remote -l
  4. ID     Done       Have  ETA           Up    Down  Ratio  Status       Name
  5.    1    100%     801 MB  Done         0.0     0.0   0.00  Stopped      linuxmint-13-cinnamon-dvd-64bit-rc.iso
  6.    2      0%   19.05 MB  1 hrs        0.0   178.0   0.00  Downloading  linuxmint-14-cinnamon-dvd-64bit-rc.iso
  7. Sum:          820.05 MB               0.0   178.0

To stop a torrent do the following (Need to know the torrent number, obtained from "transmission-remote -l")
  1. clive@dogmatix > transmission-remote -t 2 -S
  2. localhost:9091/transmission/rpc/ responded: "success"

To remove a torrent (Including the downloaded file(s)):
  1. clive@dogmatix > transmission-remote -t 2 --remove-and-delete
  2. localhost:9091/transmission/rpc/ responded: "success"

The following shows all the options available to control the Transmission client:
clive@dogmatix > transmission-remote --help
transmission-remote 2.51 (13280)
A fast and easy BitTorrent client
http://www.transmissionbt.com/

Usage: transmission-remote [host] [options]
       transmission-remote [port] [options]
       transmission-remote [host:port] [options]
       transmission-remote [http(s?)://host:port/transmission/] [options]

See the man page for detailed explanations and many examples.

Options:
 -h   --help                               Display this help page and exit
 -a   --add                                Add torrent files by filename or URL
 -as  --alt-speed                          Use the alternate Limits
 -AS  --no-alt-speed                       Don't use the alternate Limits
 -asd --alt-speed-downlimit         max alternate download speed (in
                                           kB/s)
 -asu --alt-speed-uplimit           max alternate upload speed (in kB/s)
 -asc --alt-speed-scheduler                Use the scheduled on/off times
 -ASC --no-alt-speed-scheduler             Don't use the scheduled on/off times
      --alt-speed-time-begin  


       Where to store new torrents until
                                           they're complete
 -C   --no-incomplete-dir                  Don't store incomplete torrents in a
                                           different location
 -b   --debug                              Print debugging information
 -d   --downlimit                   Set the max download speed in kB/s
                                           for the current torrent(s) or
                                           globally
 -D   --no-downlimit                       Disable max download speed for the
                                           current torrent(s) or globally
 -e   --cache                        Set the maximum size of the session's
                                           memory cache (in MiB)
 -er  --encryption-required                Encrypt all peer connections
 -ep  --encryption-preferred               Prefer encrypted peer connections
 -et  --encryption-tolerated               Prefer unencrypted peer connections
      --exit                               Tell the transmission session to shut
                                           down
 -f   --files                              List the current torrent(s)' files
 -g   --get                         Mark files for download
 -G   --no-get                      Mark files for not downloading
 -i   --info                               Show the current torrent(s)' details
 -if  --info-files                         List the current torrent(s)' files
 -ip  --info-peers                         List the current torrent(s)' peers
 -ic  --info-pieces                        List the current torrent(s)' pieces
 -it  --info-trackers                      List the current torrent(s)'
                                           trackers
 -si  --session-info                       Show the session's details
 -st  --session-stats                      Show the session's statistics
 -l   --list                               List all torrents
      --move                         Move current torrent's data to a new
                                           folder
      --find                         Tell Transmission where to find a
                                           torrent's data
 -m   --portmap                            Enable portmapping via NAT-PMP or
                                           UPnP
 -M   --no-portmap                         Disable portmapping
 -n   --auth                      Set username and password
 -ne  --authenv                            Set authentication info from the
                                           TR_AUTH environment variable
                                           (user:pw)
 -N   --netrc                        Set authentication info from a .netrc
                                           file
      --ssl                                Use SSL when talking to daemon
 -o   --dht                                Enable distributed hash tables (DHT)
 -O   --no-dht                             Disable distributed hash tables
                                           (DHT)
 -p   --port                         Port for incoming peers (Default:
                                           51413)
 -pt  --port-test                          Port testing
 -P   --random-port                        Random port for incomping peers
 -ph  --priority-high               Try to download these file(s) first
 -pn  --priority-normal             Try to download these file(s)
                                           normally
 -pl  --priority-low                Try to download these file(s) last
 -Bh  --bandwidth-high                     Give this torrent first chance at
                                           available bandwidth
 -Bn  --bandwidth-normal                   Give this torrent bandwidth left over
                                           by high priority torrents
 -Bl  --bandwidth-low                      Give this torrent bandwidth left over
                                           by high and normal priority torrents
      --reannounce                         Reannounce the current torrent(s)
 -r   --remove                             Remove the current torrent(s)
 -pr  --peers                         Set the maximum number of peers for
                                           the current torrent(s) or globally
      --remove-and-delete                  Remove the current torrent(s) and
                                           delete local data
      --torrent-done-script          Specify a script to run when a
                                           torrent finishes
      --no-torrent-done-script             Don't run a script when torrents
                                           finish
 -sr  --seedratio              ratio       Let the current torrent(s) seed until
                                           a specific ratio
 -srd --seedratio-default                  Let the current torrent(s) use the
                                           global seedratio settings
 -SR  --no-seedratio                       Let the current torrent(s) seed
                                           regardless of ratio
 -gsr --global-seedratio       ratio       All torrents, unless overridden by a
                                           per-torrent setting, should seed
                                           until a specific ratio
 -GSR --no-global-seedratio                All torrents, unless overridden by a
                                           per-torrent setting, should seed
                                           regardless of ratio
 -td  --tracker-add               Add a tracker to a torrent
 -tr  --tracker-remove         Remove a tracker from a torrent
 -s   --start                              Start the current torrent(s)
 -S   --stop                               Stop the current torrent(s)
 -t   --torrent                   Set the current torrent(s)
      --start-paused                       Start added torrents paused
      --no-start-paused                    Start added torrents unpaused
      --trash-torrent                      Delete torrents after adding
      --no-trash-torrent                   Do not delete torrents after adding
 -hl  --honor-session                      Make the current torrent(s) honor the
                                           session limits
 -HL  --no-honor-session                   Make the current torrent(s) not honor
                                           the session limits
 -u   --uplimit                     Set the max upload speed in kB/s for
                                           the current torrent(s) or globally
 -U   --no-uplimit                         Disable max upload speed for the
                                           current torrent(s) or globally
      --utp                                Enable uTP for peer connections
      --no-utp                             Disable uTP for peer connections
 -v   --verify                             Verify the current torrent(s)
 -V   --version                            Show version number and exit
 -w   --download-dir                 When adding a new torrent, set its
                                           download folder. Otherwise, set the
                                           default download folder
 -x   --pex                                Enable peer exchange (PEX)
 -X   --no-pex                             Disable peer exchange (PEX)
 -y   --lpd                                Enable local peer discovery (LPD)
 -Y   --no-lpd                             Disable local peer discovery (LPD)
 -pi  --peer-info                          List the current torrent(s)' peers