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

企业微信发送内容:

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM