shell实现发送微信文本信息

#!/bin/bash
#####################################
##    created by basededato        ##
##    2016-2-25                    ##
#####################################
. ./sys_cfg
LANG="en_US.UTF-8"
#PATH="/sbin:/usr/sbin:/usr/local/sbin:/bin:/usr/bin:/usr/local/bin:"


function output(){
local APPID=3  
local USERID=DBA_basededato
local PARTYID=1
printf '{\n'
printf '\t"touser":"'"$USERID"\"",\n"
printf '\t"toparty":"'"$PARTYID"\"",\n"
printf '\t"msgtype":"text",\n'
printf '\t"agentid":"'"$APPID"\"",\n"
printf '\t"text":{\n'
printf '\t\t"content":"'"$MSG"\""\n"
printf '\t},\n'
printf '\t"safe":"0"\n'
printf '}\n'
}


function fsmsg(){
URL="https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=$(cat $SCRIPTS_PATH/token)"
APIRETURN=`curl --data-ascii "$(output)" $URL`


RET_STR=`echo $APIRETURN|awk -F \" '{print substr($3,2,1)}'`


#输出output函数输出
#OUTPUT_TEXT=$(output)
#echo $OUTPUT_TEXT


#
#echo $APIRETURN|awk -F \" '{print substr($3,2,1)}'
#echo $APIRETURN
#echo $RET_STR
}


fsmsg




if [ "$RET_STR" != "0" ]
then 
    sh token.sh
    fsmsg
fi

你可能感兴趣的:(linux,python&&shell)