[PP-Script] Sending an SMS when done

Share your scripts or request scripts with specific features.
Forum rules
Please keep the forum clean - one topic per script. Questions not related to a specific script should be posted in Support forum.
Post Reply
nesousx
Posts: 3
Joined: 28 Sep 2014, 17:51

[PP-Script] Sending an SMS when done

Post by nesousx » 28 Sep 2014, 18:06

Hi all,

I've been trying to write a simple bash script that would send me an SMS for each successful download. The SMS must contain the item name.

This script is a bit "special", indeed, I send SMS via proprietary API offered by my mobile phone provide (French company called, Free).

The API looks like this, you have to ping the following URL (with the right user / pass and wanted message):
So far the script is not working, I will explain issues below.

There is a working python version (post below), thanks to JVM.

Code: Select all

#!/bin/sh

### NZBGET POST-PROCESSING SCRIPT

# This script sends an SMS containing item name each time a download is successful.


# if using variables....

USER=123456
PASS=R4ND0M_STUFF
MESSAGE="$NZBPP_NZBNAME"
COMMAND="https://smsapi.free-mobile.fr/sendmsg?user=$USER&pass=$PASS&msg=$MESSAGE"
echo $COMMAND

# Exit codes
POSTPROCESS_PARCHECK_CURRENT=91
POSTPROCESS_PARCHECK_ALL=92
POSTPROCESS_SUCCESS=93
POSTPROCESS_ERROR=94
POSTPROCESS_NONE=95

# Check if the script is called from nzbget
if [ "$NZBPP_DIRECTORY" = "" -o "$NZBOP_CONFIGFILE" = "" ]; then
        echo "*** NZBGet post-process script ***"
        echo "This script is supposed to be called from nzbget (0.7.0 or later)."
        exit $POSTPROCESS_ERROR
fi

# Check if postprocessing was disabled in postprocessing parameters
# (for current nzb-file) via web-interface or via command line with
# "nzbget -E G O PostProcess=no <ID>"
if [ "$NZBPR_PostProcess" = "no" ]; then
        echo "[WARNING] Post-Process: Postprocessing disabled for this nzb-file, exiting"
        exit $POSTPROCESS_NONE
fi

echo "[INFO] Post-Process: Post-process script successfully started"

if [ "$NZBPP_PARSTATUS" -eq 2 -o "$NZBPP_UNPACKSTATUS" -eq 2 ]; then
        /usr/bin/curl -sk $COMMAND

        echo "[INFO] SMS sent to $USER."
        exit $POSTPROCESS_SUCCESS
fi
Many thanks to JVM. See post below for a python version that will send SMS whether the DL fails or success.
Last edited by nesousx on 14 Oct 2014, 08:26, edited 4 times in total.

JVM
Posts: 83
Joined: 21 Oct 2013, 05:11

Re: [PP-Script] Sending an SMS on success, fix required

Post by JVM » 29 Sep 2014, 01:52

I don't know why bash doesn't work as you'd like but is python ok?

Previously I've modified the EMail.py script that comes with NZBGet to use cURL to send notifications: [PP-SCRIPT] Pushbullet notifications (Android, iOS, Chrome).

Using the pushbullet.py v11 as a base, striping out other things so it's likely to be within 160 characters, and modifying the cURL command, I've quickly come up with this, feel free to edit as you wish. I don't have a service I can test it on however:
SMS.py
Version 1.0
(3.93 KiB) Downloaded 419 times

nesousx
Posts: 3
Joined: 28 Sep 2014, 17:51

Re: [PP-Script] Sending an SMS on success, fix required

Post by nesousx » 29 Sep 2014, 07:43

Hi JVM,

It works perfectly, thanks a lot.
I was planning to do a python version but I'am still learning the language.

However, if someone can point me my error on the bash version I'd love it.

JVM
Posts: 83
Joined: 21 Oct 2013, 05:11

Re: [PP-Script] Sending an SMS when done (python)(bash need

Post by JVM » 29 Sep 2014, 12:28

Glad to see it worked for you! Also if you wanted to you could add extra stuff in the notification like download/processing times, average speeds etc. There's some example code in the v14 Pushbullet.py or EMail.py scripts.

I don't know that much about bash, but what happens if you set the url used in curl as a variable, for example:

Code: Select all

#!/bin/sh
USER=123456
PASS=R4ND0M_STUFF
MESSAGE="New stuff arrived: $NZBPP_NZBNAME"

COMMAND="https://smsapi.free-mobile.fr/sendmsg?user=$USER&pass=$PASS&msg=$MESSAGE"
echo $COMMAND
/usr/bin/curl -sk $COMMAND

nesousx
Posts: 3
Joined: 28 Sep 2014, 17:51

Re: [PP-Script] Sending an SMS when done (python)(bash need

Post by nesousx » 14 Oct 2014, 08:23

It works, thanks!

Post Reply

Who is online

Users browsing this forum: No registered users and 27 guests