shell中curl命令變量替換

變量替換腳本寫法如下,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"}

企業微信發送內容:

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章