My script won't work after a reboot

so I found a script that will send me a telegram alarm everytime transmission finishes torrent download.

When the script runs successfully once it will continue to work throughout the day however when i reboot my cloud it doesn’t work anymore.

it seems that this script will only work if I run it after an initial torrent download. so basically it doesn’t work if i run it before an initial torrent download. (but it’s strange because this script is programmed to run when torrent download finishes)

If I run it before initial torrent download = not working
If I run it after a initial torrent down load - it works and also works throughout the day

Can anyone give me some advice??

Thanks.

the script is like below:

#!/bin/sh

setting

SERVER=“9091 --auth id:pw”

TOKEN=‘000000000:AAaaAaAA’

CHAT_ID=“000000000”

URL='https://api.telegram.org/bot’$TOKEN

MSG_URL=$URL’/sendMessage?chat_id=’

sleep 1s

do

TORRENTLIST=transmission-remote $SERVER --list | sed -e '1d;$d;s/^ *//' | cut -s -d " " -f 1

for TORRENTID in $TORRENTLIST

do

DL_COMPLETED=`transmission-remote $SERVER --torrent $TORRENTID --info | grep "Percent Done: 100%"`

STATE_STOPPED=`transmission-remote $SERVER --torrent $TORRENTID --info | grep "State: Seeding\|Stopped\|Finished\|Idle"`

if [ "$DL_COMPLETED" ] && [ "$STATE_STOPPED" ]; then

    transmission-remote $SERVER --torrent $TORRENTID --remove

    curl --data-urlencode "text=$TR_TORRENT_NAME download completed." "$MSG_URL"$CHAT_ID"&"

fi

done

What version of My Cloud do you have? A first gen v4.x single bay My Cloud or second gen v2.x single bay My Cloud?

I have first gen single bay my cloud with v4 firmware

After a reboot run your script with -x like
bash -x

I suspect that before a complete download you are missing some value. Using the -x will show you how your script is executing.

Thank you. I will try it tonight!!

so this is the result i got

localhost:9091/transmission/rpc/ responded: “success”

after a while i get below line

{“ok”:true,“result”:{“message_id”:27,“from”:{“id”:518601143,“is_bot”:true,“first_name”:“XXXX”,“username”:“XXXXbot”},“chat”:{“id”:oooooo,“first_name”:“XXXX”,“last_name”:“XXX”,“type”:“private”},“date”:1529927176,“text”:“download completed.”}}W

once again typing this script before initial download didn’t do any trick

this script only worked applying it after the initial download.

My goal is to have this script working all the time even after a reboot without connecting ssh and typing this script manually.

Please help~~!

thank you.

The output you are showing is not what you get when you sh +x . It should show each line with a + sign in front of each line that is executed. like this but replace the bullet character with a + sign.
TestGen2:~# sh -x junk