變量替換腳本寫法如下,msg變量調用使用:"'"變量"'"
# cat msg.sh #!/bin/bash msg="測試腳本" curl -i -X POST -H "'Content-type':'application/json'" -d '{"msgtype":"text","text":{"content":"'"${msg}"'","mentioned_list":["@all"]}}' https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=自己的key # sh msg.sh HTTP/1.1 200 OK Server: nginx Date: Fri, 10 Dec 2021 05:58:45 GMT Content-Type: application/json; charset=UTF-8 Content-Length: 27 Connection: keep-alive Error-Code: 0 Error-Msg: ok {"errcode":0,"errmsg":"ok"}
企業微信發送內容: