The pertinent part of the script is as follows:
Code: Select all
function getTorrentStatus {
status=$( transmission-remote ${TC_ADDR}:${TC_PORT} -n ${TC_USER}:${TC_PASS} -t ${TR_TORRENT_HASH} -i | grep State | sed 's/Stat$
echo "${TR_TORRENT_NAME} $status" >> ~/verify.log
echo "$status"
}
function verifyTorrent {
# Sleep to give the torrent a moment to cool down
#sleep 30
#transmission-remote ${TC_ADDR}:${TC_PORT} -n ${TC_USER}:${TC_PASS} -t ${TR_TORRENT_HASH} -S
# Sleep to give the torrent a moment to cool down
sleep 60
transmission-remote ${TC_ADDR}:${TC_PORT} -n ${TC_USER}:${TC_PASS} -t ${TR_TORRENT_HASH} -v
}
function startTorrent {
transmission-remote ${TC_ADDR}:${TC_PORT} -n ${TC_USER}:${TC_PASS} -t ${TR_TORRENT_HASH} -s
}
function getTorrentPercentage {
percentage=$( transmission-remote ${TC_ADDR}:${TC_PORT} -n ${TC_USER}:${TC_PASS} -t ${TR_TORRENT_HASH} -i | grep 'Percent Done' | $
echo "${TR_TORRENT_NAME} PERC: $percentage" >> ~/verify.log
echo "$percentage"
}
echo "${TR_TORRENT_NAME} Processing" >> ~/verify.log
# Initiate the torrent validation
echo "${TR_TORRENT_NAME} Verification Started" >> ~/verify.log
verifyTorrent
# Get the current torrent status
verificationStatus=$( getTorrentStatus )
# Keep checking the torrent status every 10 seconds
while [ "$verificationStatus" == "Verifying" ] || [ "$verificationStatus" == "Will Verify" ]; do
sleep 60
verificationStatus=$( getTorrentStatus )
done
# Ensure the torrent is started
echo "${TR_TORRENT_NAME} Re-Starting" >> ~/verify.log
startTorrent
# Check to see if we have 100% of the torrent still
# if not then we need to exit the app
if [ "$( getTorrentPercentage )" != "100" ]; then
echo "${TR_TORRENT_NAME} Verification Failed" >> ~/verify.log
exit
fi
echo "${TR_TORRENT_NAME} Verification Passed" >> ~/verify.log
Once the event happens, the only reply I get from the server, via transmission-remote, is as follows:
Code: Select all
[17:38:50.667] JSON parse failed at pos 196834: STRAY_TOKEN -- remaining text ""result""success"
[17:38:50.668] transmission-remote: Unable to parse response "{"arguments":{"torrents":[{"error":0,"errorString":"","eta":-1,"id":1,"isFinished":false,"leftUntilDone":0,"name":"ISO cd0","peersGettingFromUs":0,"peersSendingToUs":0,"rateDownload":0,"rateUpload":0,"sizeWhenDone":1063616,"status":6,"uploadRatio":1.1255},{"error":0,"errorString":"","eta":-1,"id":2,"isFinished":false,"leftUntilDone":0,"name":"ISO cd1","peersGettingFromUs":0,"peersSendingToUs":0,"rateDownload":0,"rateUpload":0,"sizeWhenDone":553740407,"status":6,"uploadRatio":1.0300},{"error":0,"errorString":"","eta":-1,"id":3,"isFinished":false,"leftUntilDone":0,"name":"ISO cd2","peersGettingFromUs":0,"peersSendingToUs":0,"rateDownload":0,"rateUpload":0,"sizeWhenDone":544672945,"status":6,"uploadRatio":1.0783},{"error":0,"errorString":"","eta":-1,"id":4,"isFinished":false,"leftUntilDone":0,"name":"ISO cd3","peersGettingFromUs":0,"peersSendingToUs":0,"rateDownload":0,"rateU
Code: Select all
FILESET1 Will Verify
FILESET2 Verifying
FILESET3 Will Verify
FILESET1 Will Verify
FILESET2 Verifying
FILESET3 Will Verify
FILESET1 Will Verify
FILESET2 Idle
FILESET2 Re-Starting
FILESET2 PERC: 100
FILESET2 Verification Passed
FILESET2 Extraction Started
FILESET3 Verifying
FILESET1 Will Verify
FILESET3 Verifying
FILESET1 Will Verify
FILESET3 Verifying
FILESET1 Will Verify
FILESET3 Verifying
FILESET1 Will Verify
FILESET3 Idle
FILESET3 Re-Starting
FILESET3 PERC: 100
FILESET3 Verification Passed
FILESET3 Extraction Started
FILESET1 Verifying
FILESET1 Verifying
FILESET1 Verifying
FILESET1 Verifying
FILESET1 Verifying
FILESET1 Idle
FILESET1 Re-Starting
FILESET1 PERC: 100
FILESET1 Verification Passed
FILESET1 Extraction Started
FILESET5 Processing
FILESET5 Verification Started
FILESET5
FILESET5 Re-Starting
FILESET5 PERC:
FILESET5 Verification Failed
FILESET4 Processing
FILESET4 Verification Started
FILESET4
FILESET4 Re-Starting
FILESET4 PERC:
FILESET4 Verification Failed