Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

 

Code Block
languagebash
titleSMS script
#!/bin/bash
# SMS script for version 2.4.x

usage()
{
cat << EOF
usage: $0 options

OPTIONS:
   -?,-h   Show this message
   -H      Hostname or IP address
   -u      User name
   -p      Password
   -P      Phone for sending
   -m      Message for sending
EOF
}

HOSTIP=
USERNAME=
PASSWORD=
TOPHONE=
MESSAGE='Test'

while getopts “hH:u:p:P:m:” OPTION
do
     case $OPTION in
         h)
             usage
             exit 1
             ;;
         H)
             HOSTIP=$OPTARG
             ;;
         u)
             USERNAME=$OPTARG
             ;;
         p)
             PASSWORD=$OPTARG
             ;;
         P)
             TOPHONE=$OPTARG
             ;;
         m)
             MESSAGE=$OPTARG
             ;;
         ?)
             usage
             exit
             ;;
     esac
done

if [[ -z $HOSTIP ]] || [[ -z $USERNAME ]] || [[ -z $PASSWORD ]] || [[ -z $TOPHONE ]] || [[ -z $MESSAGE ]]
then
     usage
     exit 1
fi

# 1) hash
HASH=`echo -n ${PASSWORD} | openssl dgst -sha1 | awk '{print $NF}'`

# 2) autorisation
RESPONSE=`curl -s -d "querytype=auth&name=${USERNAME}&h=${HASH}" "${HOSTIP}/engine.htm"`

# 3) session key
KEY=`echo -n  ${RESPONSE} | awk -F"\"" '{print $4}'`

# 4) send SMS
curl
 -d "querytype=send_sms_message&k=${KEY}" --data-urlencode 
"to_phone=${TOPHONE}" --data-urlencode "message=${MESSAGE}" 
${HOSTIP}/engine.htm > /dev/null 2>&1

Child pages (Children Display)

 In case of errors, leave comments below on the page or on our forum. Please indicate in the message the current version of the firmware of the monitoring system (System menu → About this system → Firmware version).

developer notes: linkchange

...