sendSMS.sh #!/bin/bash # # Filename: sendSMS.sh # Revision: 2.0 # Date: 2017/01/16 # Author: zhangxun # Email: LOGFILE="/tmp/SMS.log" :>"$LOGFILE" exec 1>"$LOGFILE" exec 2>&1 MOBILE_NUMBER=$1 # 手机号码 MESSAGE_UTF8=$3 # 短信内容 XXD="/usr/bin/xxd" CURL="/usr/bin/curl" TIMEOUT=5 # 短信内容要经过URL编码处理,除了下面这种方法,也可以用curl的--data-urlencode选项实现。 MESSAGE_ENCODE=$(echo "$MESSAGE_UTF8" | ${XXD} -ps | sed 's/\(..\)/%\1/g' | tr -d '\n') # SMS API
URL="http://xxxxxx:10080/SMS/Send?sms=\{%22To%22:%22${MOBILE_NUMBER}%22,%22Text%22:%22${MESSAGE_ENCODE}%22\}" # Send it set -x ${CURL} -s --connect-timeout ${TIMEOUT} "${URL}"
https://www.zabbix.com/documentation/3.0/manual/config/notifications/media/script
http://qicheng0211.blog.51cto.com/3958621/1551105/