SCRIPT:Update a txt file with the List of downloaded torrent

Feature requests not specific to either the Mac OS X or GTK+ versions of Transmission
Post Reply
AYAMY
Posts: 6
Joined: Thu Aug 29, 2013 1:42 pm

SCRIPT:Update a txt file with the List of downloaded torrent

Post by AYAMY »

MOVED TO REQUEST


Hi everybody,
I'm new to script for trasmission so I would know if there is already this kind of script:
I would a script that when a torrent is done writes in a txt file the name of the file downloaded and each time a new download is done it appends the name of the new one torrent.
is it possible?
thanks

Simon
Last edited by AYAMY on Fri Aug 30, 2013 11:42 am, edited 2 times in total.
AYAMY
Posts: 6
Joined: Thu Aug 29, 2013 1:42 pm

Re: SCRIPT: List of torrent downloaded

Post by AYAMY »

#!/bin/bash
echo "NAME: \"$TR_TORRENT_NAME\" DIR : $TR_TORRENT_DIR\" on DATE: $TR_TIME_LOCALTIME" >> /home/myfile.txt
echo " "
Could this work?

The idea is to insert the myfile.txt on a dropbox folder so i could see from my others pc & android phones the list of downloaded torrents
(I already use dropbox folder to "feed" trasmission with .torrent files)


;)
AYAMY
Posts: 6
Joined: Thu Aug 29, 2013 1:42 pm

Re: SCRIPT: List of torrent downloaded

Post by AYAMY »

I run the script from the terminal and It writes the file without problem.
From Transmission (i have installed the full gui transmission not the deamon) the script doesn't start infact the file hasn't been generated after a torrent completed...
I have put the script in the tmp folder and the file that the script is supposed to write is in the same folder...because i have read that in the tmp folder all the applications have the privileges to write read and execute without problem...
why the script doesn't start? could you help me please
AYAMY
Posts: 6
Joined: Thu Aug 29, 2013 1:42 pm

Re: SCRIPT: List of torrent downloaded

Post by AYAMY »

Googling i have found an error --> in the script should be this : #!/bin/sh instead of #!/bin/bash
new version with log

#!/bin/sh
{
start_time=`date +%s`
# Log file, file where we tell what events have been processed.
LOG=/tmp/LogTorrentScript.txt
echo "Now Listy Script Torrent runs" > $LOG 2>&1
echo $start_time >> $LOG 2>&1
echo "***************************************" >> $LOG 2>&1
echo "NAME: \"$TR_TORRENT_NAME\" DIR : $TR_TORRENT_DIR\" on DATE: $TR_TIME_LOCALTIME" >> /tmp/ListDownloadedTorrent.txt
end_time=`date +%s`
echo "***************************************" >> $LOG 2>&1
}
blacke4dawn
Posts: 552
Joined: Sun Dec 13, 2009 10:44 pm

Re: SCRIPT: List of torrent downloaded

Post by blacke4dawn »

AYAMY wrote:Googling i have found an error --> in the script should be this : #!/bin/sh instead of #!/bin/bash
Technically not an error since it only says what binary to use to run the script through. The reason for using /bin/sh is that in many cases it points to the default shell (itself just being a symbolic link), and for backwards compatibility.

The line:

Code: Select all

echo "Now Listy Script Torrent runs" > $LOG 2>&1
will "reset" the log every time this script is run. Using a single > will first clear the file of any content it might have.


Personally I would just use something like this:

Code: Select all

#!/bin/bash
echo "$(date +%F %T): Downloaded \"${TR_TORRENT_NAME}\" to ${TR_TORRENT_DIR}" >> /dir/for/dropbox/torrents.txt[code]I'm using #!/bin/bash here because I'm using bash specific syntax.

The two things you have to make sure of is that Transmission has access to the script and that it is runable. By "access to it" I mean that the user Transmission runs as has read-access any directory (and sub-directory) it is under (easiest by placing it in /usr/local/bin), and making it runable is just setting the permission bits to 0755. Now if Transmission is not run under your own account then you would have to make sure it has write access to the dropbox directory.
AYAMY
Posts: 6
Joined: Thu Aug 29, 2013 1:42 pm

Re: SCRIPT:Update a txt file with the List of downloaded tor

Post by AYAMY »

sorry... but how can i make sure that Transmission have the write access to my dropbox directory ? do i have to create a transmission group and set the privileges of this group to have write access to the parent dropbox folder ? how can i make it? thanks !!!!
blacke4dawn
Posts: 552
Joined: Sun Dec 13, 2009 10:44 pm

Re: SCRIPT:Update a txt file with the List of downloaded tor

Post by blacke4dawn »

There are a few ways to do it, though Transmission only needs write access to the folder if you want it to be able to create new files. If you want it to only be able to modify an existing one the write access to that file is enough. For any other folder in that path it only needs execute permission. Since you don't say which flavor you run (GTK, daemon, QT, cli) then I'm not even sure if this is even needed in the first place but since you are asking about it then I assume it is.

1) The easiest solution would probably be to just add the account that transmission runs under to your primary group (most likely "users" or one with the same name as your account). Make sure to restart Transmission afterwards.

2) As you suggest, creating a group specifically for this purpose and adding both your account and the account that Transmission runs under. Restart Transmission and logout/login afterwards, and if you need it on the directory then it would probably be best to set the setgid bit so that the group is pserved for the files created inside said directory.

3) Changing the account that Transmission runs under to the one you are using. Since you don't say which distribution you are running then I can't say how to do so.

4) Using "extended" ACL's to add Transmissions account to said file and path in addition to your own (using setfacl/getfacl), though this needs to be activated for the filesystem first (mount-option "acl").
Post Reply