微信报警脚本

时间:2018-12-05 10:25:55   收藏:0   阅读:239
 1 #!/bin/bash
 2 #====================================================
 3 # Author: VizierBi
 4 # Create Date: 2018-10-19
 5 # Description:微信监控报警脚本 
 6 #====================================================
 7 CropID=‘wwaebf94b1310467a9‘
 8 Secret=‘W6ahrPd1vg-M2I1CbXa9MYhRW_Vp10NNmOQNov2ELvY‘
 9 GURL="https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=$CropID&corpsecret=$Secret"
10 Gtoken=$(/usr/bin/curl -s -G $GURL | awk -F\" ‘{print $10}‘)
11 PURL="https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=$Gtoken"
12 
13 function body(){
14     local int AppID=1000002
15     local UserID=$1
16     local PartyID=1
17     local Msg=$(echo "$@" | cut -d" " -f3-)
18     printf ‘{\n‘
19     printf ‘\t"touser": "‘"$User"\"",\n"
20     printf ‘\t"toparty": "‘"$PartyID"\"",\n"
21     printf ‘\t"msgtype": "text",\n‘
22     printf ‘\t"agentid": "‘" $AppID "\"",\n"
23     printf ‘\t"text": {\n‘
24     printf ‘\t\t"content": "‘"$Msg"\""\n"
25     printf ‘\t},\n‘
26     printf ‘\t"safe":"0"\n‘
27     printf ‘}\n‘
28 }
29 /usr/bin/curl --data-ascii "$(body $1 $2 $3)" $PURL

 

评论(0)
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!