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"}

企业微信发送内容:

 

posted @ 2021-12-10 14:02  林中龙虾  阅读(952)  评论(0编辑  收藏  举报