Page 1 of 1
ubuntu 12.04 server ,environment variables hold nothing
Posted: Tue Mar 12, 2013 4:08 am
by nanjifeng
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 ?
Re: ubuntu 12.04 server ,environment variables hold nothing
Posted: Tue Mar 12, 2013 5:38 am
by rb07
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}
You have a typo (in bold).
Re: ubuntu 12.04 server ,environment variables hold nothing
Posted: Tue Mar 12, 2013 6:02 am
by nanjifeng
rb07 wrote: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}
You have a typo (in bold).
thanks .I did not notice that .
however, the question is that , this line does not generate any output ? why ?
Re: ubuntu 12.04 server ,environment variables hold nothing
Posted: Tue Mar 12, 2013 11:54 am
by blacke4dawn
nanjifeng wrote:rb07 wrote: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}
You have a typo (in bold).
thanks .I did not notice that .
however, the question is that , this line does not generate any output ? why ?
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.
Re: ubuntu 12.04 server ,environment variables hold nothing
Posted: Tue Mar 12, 2013 1:55 pm
by nanjifeng
blacke4dawn wrote:nanjifeng wrote:
thanks .I did not notice that .
however, the question is that , this line does not generate any output ? why ?
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.
thank u!
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
Posted: Wed Mar 13, 2013 6:18 am
by nanjifeng
hi,I did the following test using following scripts from
https://trac.transmissionbt.com/browser ... nt-done.sh with a different mail tool;
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)
scripts is saved in the directory :/etc/transmission-daemon/scripts/after.sh
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?
Re: ubuntu 12.04 server ,environment variables hold nothing
Posted: Wed Mar 13, 2013 8:32 am
by blacke4dawn
nanjifeng wrote:scripts is saved in the directory :/etc/transmission-daemon/scripts/after.sh
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.
Re: ubuntu 12.04 server ,environment variables hold nothing
Posted: Thu Mar 14, 2013 1:08 am
by nanjifeng
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 ?