OS: Ubuntu 12.04 Server Edition 64bit
Linux ubuntu 3.2.0-29-generic #46-Ubuntu SMP Fri Jul 27 17:03:23 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
transmission-daemon:
root@ubuntu:~# transmission-daemon -V
transmission-daemon 2.51 (13280)
I want to get the torrent name when one torrent is completed. The following script is tested:
#after.sh
#!/bin/sh
# Log file, file where we tell what events have been processed.
# Get current time.
NOW=$(date +%Y-%m-%d\ %H:%M:%S)
LOGFILE=/var/log/transmission.log
# Source directory, should not be changed.
SRC_DIR=${TR_TORRENT_DIR}/${TR_TORRENT_NAME}
echo "torrent : ${SRC_DIR} FINISH AT ${NOW}"
echo "torrent : ${SRC_DIR} FINISH AT ${NOW}" >> ${LOGFILE}
echo ${NOW};
echo $TR_TORRENT_NAME;
only get the following output:
root@ubuntu:~/transmission-daemon/scripts# ./after.sh
torrent : / FINISH AT 2013-03-12 13:58:09
2013-03-12 13:58:09
help. Is there anyting i missed ?
ubuntu 12.04 server ,environment variables hold nothing
ubuntu 12.04 server ,environment variables hold nothing
Last edited by nanjifeng on Tue Mar 12, 2013 6:03 am, edited 1 time in total.
Re: ubuntu 12.04 server ,environment variables hold nothing
You have a typo (in bold).nanjifeng wrote:SRC_DIR=${TR_TORRENT_DIR}/${TR_TORRENT_NAME}
echo "torrent : ${SRC_DRI} FINISH AT ${NOW}"
echo "torrent : ${SRC_DRI} FINISH AT ${NOW}" >> ${LOGFILE}
Re: ubuntu 12.04 server ,environment variables hold nothing
thanks .I did not notice that .rb07 wrote:You have a typo (in bold).nanjifeng wrote:SRC_DIR=${TR_TORRENT_DIR}/${TR_TORRENT_NAME}
echo "torrent : ${SRC_DRI} FINISH AT ${NOW}"
echo "torrent : ${SRC_DRI} FINISH AT ${NOW}" >> ${LOGFILE}
however, the question is that , this line does not generate any output ? why ?
Code: Select all
echo $TR_TORRENT_NAME;
-
- Posts: 552
- Joined: Sun Dec 13, 2009 10:44 pm
Re: ubuntu 12.04 server ,environment variables hold nothing
If you are running it from the command line (as it seems you are doing in the OP to test if it works) then you have to initialize the TR variables yourself, how you done so? Otherwise they will be completely empty and thus not produce any output.nanjifeng wrote:thanks .I did not notice that .rb07 wrote:You have a typo (in bold).nanjifeng wrote:SRC_DIR=${TR_TORRENT_DIR}/${TR_TORRENT_NAME}
echo "torrent : ${SRC_DRI} FINISH AT ${NOW}"
echo "torrent : ${SRC_DRI} FINISH AT ${NOW}" >> ${LOGFILE}
however, the question is that , this line does not generate any output ? why ?Code: Select all
echo $TR_TORRENT_NAME;
Re: ubuntu 12.04 server ,environment variables hold nothing
thank u!blacke4dawn wrote:If you are running it from the command line (as it seems you are doing in the OP to test if it works) then you have to initialize the TR variables yourself, how you done so? Otherwise they will be completely empty and thus not produce any output.nanjifeng wrote: thanks .I did not notice that .
however, the question is that , this line does not generate any output ? why ?Code: Select all
echo $TR_TORRENT_NAME;
you are right.I did the above test from secureCRT. I thought the TR variables were initialized by transmission-daemon once they were started.
Let me try your way.
Re: ubuntu 12.04 server ,environment variables hold nothing
hi,I did the following test using following scripts from https://trac.transmissionbt.com/browser ... nt-done.sh with a different mail tool;
add a .torrent and still i got nothing in my email box.
scripts is saved in the directory :/etc/transmission-daemon/scripts/after.sh
mail logs shows there is no mail sent and received.
So,here is my question:
In the syslog,I can see transmission-daemon try to call the script.
Does it succeed in calling the script or threre is something wrong with script?
Code: Select all
#!/bin/sh
##
## User-configurable Variables
##
# Where "nail" is installed on your system.
# We need this to actually send the mail, so make sure it's installed
MUTT=/usr/bin/mutt
# REQUIRED CHANGE #1: you must set SMTP_SERVER
# http://www.host45.com/resources/ispsmtps.php has a list of ISP's smtp servers
#SMTP_SERVER=smtp.qq.com
# REQUIRED CHANGE #2: you must set your email address.
# option A: change "yourname@yourmail.com" here and remove the leading '#' to
# use a real email address
TO_ADDR=nanjifengwww@qq.com
#
###
### Send the mail...
###
SUBJECT="Torrent Done!"
FROM_ADDR="transmission@localhost.localdomain"
TMPFILE=`mktemp -t transmission.XXXXXXXXXX`
echo "Transmission finished downloading \"$TR_TORRENT_NAME\" on $TR_TIME_LOCALTIME" >$TMPFILE
$MUTT -s "$SUBJECT" -- "$TO_ADDR" < $TMPFILE
rm $TMPFILE
add a .torrent and still i got nothing in my email box.
Code: Select all
root@ubuntu:~# tail -n 100 /var/log/syslog
Mar 13 14:07:15 ubuntu transmission-daemon[5273]: Saved "/etc/transmission-daemon/torrents/A Midsummer Night's Dream - William Shakespeare.a6d1f4f763ccbddf.torrent" (bencode.c:1731)
Mar 13 14:07:15 ubuntu transmission-daemon[5273]: A Midsummer Night's Dream - William Shakespeare Queued for verification (verify.c:260)
Mar 13 14:07:15 ubuntu transmission-daemon[5273]: A Midsummer Night's Dream - William Shakespeare Verifying torrent (verify.c:218)
Mar 13 14:07:21 ubuntu transmission-daemon[5273]: A Midsummer Night's Dream - William Shakespeare Retrying announce in 342 seconds. (announcer.c:999)
Mar 13 14:07:55 ubuntu transmission-daemon[5273]: A Midsummer Night's Dream - William Shakespeare State changed from "Incomplete" to "Complete" (torrent.c:2042)
Mar 13 14:07:55 ubuntu transmission-daemon[5273]: A Midsummer Night's Dream - William Shakespeare Calling script "/root/transmission-daemon/scritps/after.sh" (torrent.c:2000)
Code: Select all
-rwxrwxrwx 1 debian-transmission debian-transmission 828 Mar 13 13:47 after.sh
mail logs shows there is no mail sent and received.
So,here is my question:
In the syslog,I can see transmission-daemon try to call the script.
Does it succeed in calling the script or threre is something wrong with script?
-
- Posts: 552
- Joined: Sun Dec 13, 2009 10:44 pm
Re: ubuntu 12.04 server ,environment variables hold nothing
Maybe so but it's not the one set to be used by Transmission, it says /root not /etc in the log-output you provided.nanjifeng wrote:scripts is saved in the directory :/etc/transmission-daemon/scripts/after.sh
Re: ubuntu 12.04 server ,environment variables hold nothing
sorry, my spelling mistake again.
the scripts is actually saved in the /root/transmission-daemon/scripts.
I have to say,this is a wiered question.I read posts about ubuntu and transmission-daemon in the forum.It seems that someone has succeed and other hasn't. But those have difficulty at the very beiginning and got it worked in the end did not give any clues.
I have tried this scripts on debian 6 and got the same result. As suggested, I want to tell if it is problem of privileges.I change transmission-daemon user from debian-transmission to root.
everything works!
I try this way on my ubuntu 12.04 server edition, problem remains.
what the hell!
what is the problem ?
the scripts is actually saved in the /root/transmission-daemon/scripts.
I have to say,this is a wiered question.I read posts about ubuntu and transmission-daemon in the forum.It seems that someone has succeed and other hasn't. But those have difficulty at the very beiginning and got it worked in the end did not give any clues.
I have tried this scripts on debian 6 and got the same result. As suggested, I want to tell if it is problem of privileges.I change transmission-daemon user from debian-transmission to root.
everything works!
I try this way on my ubuntu 12.04 server edition, problem remains.
what the hell!
what is the problem ?