Help with Post-Processing Script - Move based on tracker

Feature requests not specific to either the Mac OS X or GTK+ versions of Transmission
JeanVW14
Posts: 8
Joined: Sat May 24, 2014 11:47 am

Help with Post-Processing Script - Move based on tracker

Post by JeanVW14 »

Hi All

First time poster here - I have searched the forums, and looked at the different boards so I'm hoping this is the right forum for this..(?). I have no experience with scripting beyond the basic stuff, so please forgive me if it is anything obvious.

I was looking for a post-processing script that moves files based on the tracker, more specifically only moves files from a single tracker away from the default, rather than streaming a bunch across different folders. I came across this great script that seemed perfect - https://github.com/jturnbull/transmissi ... by-tracker. The code is as below...

#!/bin/sh

REMOTE="transmission-remote localhost:40000 -n user:password""
DESTDIR="/mnt/sda1/download/music"
TRACKER="ubuntu\.com"
IDLIST="$($REMOTE -l | tail -n +2 | grep 100% | grep -v Stopped | awk '{ print $1; }')"


for ID in $IDLIST; do
TRACKER="$($REMOTE --torrent $ID -it | grep '$TRACKER')"
if [ $? -eq 0 ]; then
MOVED="$($REMOTE --torrent $ID -i | grep $DESTDIR)"
if [ $? -eq 1 ]; then
RESULT="$($REMOTE --torrent $ID --move $DESTDIR)"
echo "Moved $ID"
fi
fi
done

The problem is that it doesn't do what I was hoping - the downloads go into the main download directory with everything else.

Heres what I have done / tried to get it going -

I have changed all the variables to suit my case, password ports, etc.. all working well on separate commands.
Made the script executable, and Changed the script permissions to 777. so there should be no permission issues.
Included an ‘echo to log file’ line in it to see if it was actually running on complete - it was.
Removed all spaces from the destination folder name.
Checked the tracker ID separately through transmission-remote, and tried a bunch of variants of the tracker.. "http://www.tracker.com, tracker.com, http://www.tracker.com:80", etc…
Run all the commands separately out of the script - e.g. transmission-remote *blah Blah*, and it is behaving itself.

None of this has worked when put together though, and I'm out of ideas. I have mailed the script author on Github, and there has been no response - it was written over 2 years ago, so perhaps he has lost interest now. I was hoping that a knowledgable user out there could just check the syntax for me to make sure that it looks right..? Or just point me in the right direction..?

There is another feature that I would like to add eventually to the script - apply upload ratio limits to downloads that are NOT from this tracker, but seed downloads from this tracker indefinitely, but that is perhaps a next step that I will try to see if I can get on my own steam later.

Thanks in advance,
Jean
rb07
Posts: 1400
Joined: Sun Aug 24, 2008 3:14 am

Re: Help with Post-Processing Script - Move based on tracker

Post by rb07 »

JeanVW14 wrote:I'm hoping this is the right forum for this
No, wrong forum, you should have used "General Support" (Requests are for requesting changes to the functionality of the program -- in fact the description is there, below the forum name).
JeanVW14 wrote:to make sure that it looks right
The first line may cause problems, /bin/sh (which in some Linux systems, but not all, is the same as /bin/bash) doesn't have the execute function "$(...)". The quoting used in the TRACKER line is wrong (that script never worked), and changing TRACKER in that line just messes up everything.

You don't need to delete spaces from directories, or file names, just add quotes around them.

Important: don't assume the PATH exist or is the same you get in a shell, use full paths:

Code: Select all

#!/bin/bash

HOST=localhost
PORT=40000
USER=user
PASS=password
TR=/usr/bin/transmission-remote
REMOTE="$TR $HOST:$PORT -n $USER:$PASS"
DESTDIR="/mnt/sda1/download/music"
TRACKER="ubuntu\.com"

IDLIST="$($REMOTE -l | tail -n +2 | grep 100% | grep -v Stopped | awk '{ printf "%d\n",$1; }')"

for ID in $IDLIST; do
  $REMOTE -t $ID -it | grep -i "$TRACKER"
  if [ $? -eq 0 ]; then
    $REMOTE -t $ID -i | grep "$DESTDIR"
    if [ $? -eq 1 ]; then
      $REMOTE -t $ID --move "$DESTDIR"
      echo "Moved $ID"
    fi
  fi
done
Not tested.
Last edited by rb07 on Mon May 26, 2014 6:43 pm, edited 3 times in total.
JeanVW14
Posts: 8
Joined: Sat May 24, 2014 11:47 am

Re: Help with Post-Processing Script - Move based on tracker

Post by JeanVW14 »

Firstly, apologies for using the wrong forum - Perhaps an admin out there could move it..?

Then RB07 - THANK YOU for your help.. very comprehensive. I'll give it a try now, and let you know.

Ta,
Jean
rb07
Posts: 1400
Joined: Sun Aug 24, 2008 3:14 am

Re: Help with Post-Processing Script - Move based on tracker

Post by rb07 »

My version of the script had one to many quotes (at the end) on line REMOTE=...
JeanVW14
Posts: 8
Joined: Sat May 24, 2014 11:47 am

Re: Help with Post-Processing Script - Move based on tracker

Post by JeanVW14 »

I saw that.. thanks!

So I've had the script run a few times on torrents completing from the particular tracker, and none of them were moved. I'm guessing that it might be syntax of how I am entering the tracker ID under variables ($TRACKER). If I use transmission-remote to list the tracker, it lists as "http://www.tracker.com:80". I tried that. I also tried "tracker.com" but no luck. I also see that the format from the original script is "tracker\.com".

Is the backslash necessary within the variable before the ".", and could this be the reason?

Thanks again,
Jean
radir
Posts: 18
Joined: Sat Apr 18, 2009 4:47 pm

Re: Help with Post-Processing Script - Move based on tracker

Post by radir »

Hi,

the most important step is missing ... the actual move.

Code: Select all

    for ID in $IDLIST; do
      $REMOTE -t $ID -it | grep -i \"$TRACKER\"
      if [ $? -eq 0 ]; then
        # change torrent location to $DESTDIR
        $REMOTE -t $ID --move "$DESTDIR"
        # moving can be quite slow maybe worth to wait a bit
        # sleep 30
        $REMOTE -t $ID -i | grep \"$DESTDIR\"
        if [ $? -eq 1 ]; then
          $REMOTE -t $ID --move \"$DESTDIR\"
          echo "Moved $ID"
        fi
      fi
    done
rb07
Posts: 1400
Joined: Sun Aug 24, 2008 3:14 am

Re: Help with Post-Processing Script - Move based on tracker

Post by rb07 »

JeanVW14:
Quoting the dot is harmless, and not needed.

I don't understand your comment about "($TRACKER)"... did you change anything? (because there is no $TRACKER between parenthesis, its between quoted quotes (and that's the way it should be, not the original single quotes, which was a BIG mistake).

OK, basic shell debugging, add this to the top of the script. Where the location of the log file is something you have to define (the $$ means the actual name is the process id of the daemon):

Code: Select all

#!/bin/bash -x

# DEBUG
LOG=/opt/var/tmp/$$.log
exec > $LOG 2>&1

Check the log after its run by the daemon. The "-x" parameter to bash will make it log everything it does (making the log somewhat hard to read, you get what the shell is interpreting, then the execution of each command, then any output, and so on).

radir:
You're wrong. Transmission-remote sends the move command to the daemon, and that's it, it doesn't matter how long it takes to make the actual move, the daemon changes its metainfo an that takes no time.
JeanVW14
Posts: 8
Joined: Sat May 24, 2014 11:47 am

Re: Help with Post-Processing Script - Move based on tracker

Post by JeanVW14 »

So after including the log line, and reading the first log, the script was not finding the transmission-remote program at /bin/, so I repointed it to /usr/bin.

Then I ran it again, and the file was not moved, but the log file is as below..

Once again, thanks for all your help guys!

Code: Select all

+ HOST=localhost
+ PORT=40000
+ USER=user
+ PASS=password
+ TR=/usr/bin/transmission-remote
+ REMOTE='/usr/bin/transmission-remote localhost:40000 -n user:password'
+ DESTDIR='/home/user/Videos/Sport/Road Cycling/'
+ TRACKER=http://www.cyclingtorrents.nl
++ /usr/bin/transmission-remote localhost:40000 -n user:password -l
++ grep 100%
++ tail -n +2
++ grep -v Stopped
++ awk '{ print $1; }'
+ IDLIST='1
2
4
5*
6
7*
8
9
10
11
12
13*
14
15*
16
18*
19
20
21
22*
23
25*
26
27
29
30*
31
32
33*
34
35
37*
38
39
40
41
43*
44
45
46
47
48
49
50
51
52*
53
54
55
57
58
59
60
62
63
64
65
66*
67
69
70
71
73
74
75
76*
77
78*
79
80
81*
82
83
84
85
92'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 1 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 2 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 4 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ grep -i '"http://www.cyclingtorrents.nl"'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t '5*' -it
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 6 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ grep -i '"http://www.cyclingtorrents.nl"'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t '7*' -it
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ grep -i '"http://www.cyclingtorrents.nl"'
01 -n user:password -t 8 -it
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 9 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 10 -it
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ grep -i '"http://www.cyclingtorrents.nl"'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 11 -it
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 12 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t '13*' -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ grep -i '"http://www.cyclingtorrents.nl"'
01 -n user:password -t 14 -it
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t '15*' -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 16 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ grep -i '"http://www.cyclingtorrents.nl"'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t '18*' -it
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 19 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 20 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 21 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t '22*' -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 23 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ grep -i '"http://www.cyclingtorrents.nl"'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t '25*' -it
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 26 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ grep -i '"http://www.cyclingtorrents.nl"'
01 -n user:password -t 27 -it
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 29 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t '30*' -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 31 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ grep -i '"http://www.cyclingtorrents.nl"'
01 -n user:password -t 32 -it
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t '33*' -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 34 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 35 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t '37*' -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 38 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 40 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t '43*' -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 44 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 45 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 46 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ grep -i '"http://www.cyclingtorrents.nl"'
01 -n user:password -t 47 -it
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ grep -i '"http://www.cyclingtorrents.nl"'
01 -n user:password -t 48 -it
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 49 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ grep -i '"http://www.cyclingtorrents.nl"'
01 -n user:password -t 50 -it
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 51 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t '52*' -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 53 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 54 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 55 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 57 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 58 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ grep -i '"http://www.cyclingtorrents.nl"'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 59 -it
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 60 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 62 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ grep -i '"http://www.cyclingtorrents.nl"'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 63 -it
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 64 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 65 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ grep -i '"http://www.cyclingtorrents.nl"'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t '66*' -it
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 67 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 69 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 70 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 71 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 73 -it
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 74 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 75 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t '76*' -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 77 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ grep -i '"http://www.cyclingtorrents.nl"'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t '78*' -it
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 79 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 80 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ grep -i '"http://www.cyclingtorrents.nl"'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t '81*' -it
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 82 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 83 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 84 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ grep -i '"http://www.cyclingtorrents.nl"'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 85 -it
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 92 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'

rb07
Posts: 1400
Joined: Sun Aug 24, 2008 3:14 am

Re: Help with Post-Processing Script - Move based on tracker

Post by rb07 »

Torrents with error (those with an asterisk after the ID) will prevent the script from working...

Since the script didn't found a single match, lets fix that changing the following line:

Code: Select all

IDLIST="$($REMOTE -l | tail -n +2 | grep 100% | grep -v Stopped | awk '{ printf "%d\n",$1; }')"
I'll add that change above, to my comment with the script.
JeanVW14
Posts: 8
Joined: Sat May 24, 2014 11:47 am

Re: Help with Post-Processing Script - Move based on tracker

Post by JeanVW14 »

I made that change to that line, but nothing has moved from the standard directory just yet.. Could I be stating the tracker name wrong? Perhaps try cycling torrents.nl?

Code: Select all

+ HOST=localhost
+ PORT=40000
+ USER=user
+ PASS=password
+ TR=/usr/bin/transmission-remote
+ REMOTE='/usr/bin/transmission-remote localhost:40000 -n user:password'
+ DESTDIR='/home/user/Videos/Sport/Road Cycling/'
+ TRACKER=http://www.cyclingtorrents.nl
++ grep 100%
++ tail -n +2
++ awk '{ printf "%d\n",$1; }'
++ /usr/bin/transmission-remote localhost:40000 -n user:password -l
++ grep -v Stopped
+ IDLIST='1
2
4
5
6
7
8
9
10
11
12
13
14
15
16
18
19
20
21
22
23
25
26
27
29
30
31
32
33
34
35
37
38
39
40
41
43
44
45
46
47
48
49
50
51
52
53
54
55
57
58
59
60
62
63
64
65
66
67
69
70
71
73
74
75
76
77
78
79
80
81
82
83
84
85
92
93'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 1 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 2 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 4 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ grep -i '"http://www.cyclingtorrents.nl"'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 5 -it
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ grep -i '"http://www.cyclingtorrents.nl"'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 6 -it
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ grep -i '"http://www.cyclingtorrents.nl"'
01 -n user:password -t 7 -it
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 8 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 9 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 10 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 11 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 12 -it
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 13 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 14 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 15 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ grep -i '"http://www.cyclingtorrents.nl"'
01 -n user:password -t 16 -it
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 18 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 19 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 20 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 21 -it
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 22 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 23 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 25 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 26 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 27 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ grep -i '"http://www.cyclingtorrents.nl"'
01 -n user:password -t 29 -it
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 30 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 31 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 32 -it
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 33 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 34 -it
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ grep -i '"http://www.cyclingtorrents.nl"'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 35 -it
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 37 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 38 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ grep -i '"http://www.cyclingtorrents.nl"'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 39 -it
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 40 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 41 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ grep -i '"http://www.cyclingtorrents.nl"'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 43 -it
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ grep -i '"http://www.cyclingtorrents.nl"'
01 -n user:password -t 44 -it
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 45 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 46 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 47 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 48 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ grep -i '"http://www.cyclingtorrents.nl"'
01 -n user:password -t 49 -it
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 51 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 52 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 53 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 54 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ grep -i '"http://www.cyclingtorrents.nl"'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 55 -it
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 57 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 58 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 59 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 60 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 62 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ grep -i '"http://www.cyclingtorrents.nl"'
01 -n user:password -t 63 -it
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 64 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 65 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 66 -it
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ grep -i '"http://www.cyclingtorrents.nl"'
01 -n user:password -t 67 -it
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 69 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ grep -i '"http://www.cyclingtorrents.nl"'
01 -n user:password -t 70 -it
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 71 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 73 -it
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 74 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ grep -i '"http://www.cyclingtorrents.nl"'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 76 -it
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 77 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 78 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 79 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 80 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 82 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 83 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 84 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 85 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 92 -it
+ '[' 1 -eq 0 ']'
+ for ID in '$IDLIST'
+ /usr/bin/transmission-remote localhost:40000 -n user:password -t 93 -it
+ grep -i '"http://www.cyclingtorrents.nl"'
+ '[' 1 -eq 0 ']'
rb07
Posts: 1400
Joined: Sun Aug 24, 2008 3:14 am

Re: Help with Post-Processing Script - Move based on tracker

Post by rb07 »

JeanVW14 wrote:Could I be stating the tracker name wrong? Perhaps try cycling torrents.nl?
There's nothing wrong with that, I would prefer the later form, just because its shorter.

There's something wrong with the script, I thought is was related to the extra asterisk, but your latest output shows it again: the lines that don't start with "+" (those are actual command output, not bash interpreter output), there's only lines like "01 -n user:password -t 7 -it", and it seems to skip those. I don't know what's going on there, where the "01" comes from. Are you re-defining TRACKER? like the original script did wrongly.
rb07
Posts: 1400
Joined: Sun Aug 24, 2008 3:14 am

Re: Help with Post-Processing Script - Move based on tracker

Post by rb07 »

Actually a lot of quoting I did is not needed, it was for the original script which had a lot of $(...) so I quoted things inside the parenthesis, but those were not needed and I changed them... so I'll change again the script on comment #2.
JeanVW14
Posts: 8
Joined: Sat May 24, 2014 11:47 am

Re: Help with Post-Processing Script - Move based on tracker

Post by JeanVW14 »

Mmm. I'm not sure. The script as it stands is posted below.

(Thanks for explaining how the asterisks work.. I'm keen to learn and its useful)

Code: Select all

#!/bin/bash -x

# DEBUG
LOG=/home/user/Downloads/Complete/Unsorted/$$.log
exec > $LOG 2>&1

HOST=localhost
PORT=40000
USER=user
PASS=password
TR=/usr/bin/transmission-remote
REMOTE="$TR $HOST:$PORT -n $USER:$PASS"
DESTDIR="/home/user/Videos/Sport/Road Cycling/"
TRACKER="http://www.cyclingtorrents.nl"

IDLIST="$($REMOTE -l | tail -n +2 | grep 100% | grep -v Stopped | awk '{ printf "%d\n",$1; }')"

for ID in $IDLIST; do
  $REMOTE -t $ID -it | grep -i \"$TRACKER\"
  if [ $? -eq 0 ]; then
    $REMOTE -t $ID -i | grep \"$DESTDIR\"
    if [ $? -eq 1 ]; then
      $REMOTE -t $ID --move \"$DESTDIR\"
      echo "Moved $ID"
    fi
  fi
done
rb07
Posts: 1400
Joined: Sun Aug 24, 2008 3:14 am

Re: Help with Post-Processing Script - Move based on tracker

Post by rb07 »

The only difference is that I removed the unneeded back slashes.

That was not creating the weirdness. I'll have to start actually running what I wrote, I'll report back if/when I find the problem.
JeanVW14
Posts: 8
Joined: Sat May 24, 2014 11:47 am

Re: Help with Post-Processing Script - Move based on tracker

Post by JeanVW14 »

Sure.. thanks!
Post Reply