发送短信脚本
这个是发送短信的脚本
代码语言:javascript复制[root@redis-b sms_script]# cat sms_sent_message.bash
#!/bin/bash
##
#$1 is phone number list
#$2 is messages with utf-8
#
help_info()
{
cat <<EOF
usage:$0 <'phone_numbers'> <'message'>
Example:$0 '18016017077,18016017078' '你好'
output:
will get the jason response something like
{
"Rets": [
{
"Rspcode": 0,
"Msg_Id": " 114445276129660989",
"Mobile": "18016017077"
},
{
"Rspcode": 0,
"Msg_Id": " 114445276129660991",
"Mobile": "18016017078"
}
]
}
More: <'phone_numbers'> <'message'> must be specified and only two args
it need two args and only two args
EOF
}
## simple check for input args
if [ "$#" -ne "2" ]
then
help_info
exit 1
fi
##
## need to be specified in CLI
mobile="$1"
content="$2"
## config area
## need to be configed manually
QTOOLS=/tmp/sms_script/qtools
CURL=/usr/bin/curl
account='xxxxxxx'
password='xxxxxxx'
## auto config
timestamps=`date %s`
timestamps=$timestamps'000'
url='http://139.129.128.71:8086/msgHttp/json/mt'
## generate args for curl
url_account=`$QTOOLS urlencode "$account"`
url_pass_temp=`echo -n "$password$mobile$timestamps"|md5sum | awk '{print $1}' `
url_pass=`$QTOOLS urlencode "$url_pass_temp"`
url_time=`$QTOOLS urlencode "$timestamps"`
url_mobile=`$QTOOLS urlencode "$mobile"`
url_content=`$QTOOLS urlencode "$content"`
$CURL -X POST "$url" -d "account=$url_account&password=$url_pass&mobile=$url_mobile&content=$url_content×tamps=$url_time"
[root@redis-b sms_script]# ./sms_sent_message.bash
usage:./sms_sent_message.bash <'phone_numbers'> <'message'>
Example:./sms_sent_message.bash '18016017077,18016017078' '你好'
output:
will get the jason response something like
{
"Rets": [
{
"Rspcode": 0,
"Msg_Id": " 114445276129660989",
"Mobile": "18016017077"
},
{
"Rspcode": 0,
"Msg_Id": " 114445276129660991",
"Mobile": "18016017078"
}
]
}
More: <'phone_numbers'> <'message'> must be specified and only two args
it need two args and only two args
[root@redis-b sms_script]#
[root@redis-b sms_script]# ./sms_sent_message.bash '15016017077' '高级报警测试
> abcdefghijklmnopqrstuvwxyz
> hello!
> over'
{
"Rets":[
{
"Rspcode":0,
"Msg_Id":"214531233876240942",
"Mobile":"15016017077",
"Fee":1
}
]
}
[root@redis-b sms_script]#