前 3 个变量将始终没有空格。第四个“ slacksitename
”有空格
ip=“x.x.x.x"
record_name=“demo.xyz"
slackuri:”WEBHOOK"
slacksitename:”123 Main St"
使用 cURL 调用时
curl -X POST -H 'Content-type: application/json' --data '{"text":"’$slacksitename': '$ip' '$record_name' DDNS updated.”}’ $slackuri
输出如下:
curl -X POST -H 'Content-type: application/json' --data '{"text":"123' Main 'St: x.x.x.x demo.xyz DDNS updated."}' https://hooks.slack.com/services/……..
curl: (6) Could not resolve host: Main
curl: (3) unmatched close brace/bracket in URL position 59:
St: x.x.x.x demo.xyz DDNS updated."
有谁知道它为什么要添加单引号123' Main 'St
?以及我如何将整个变量视为一个字符串而不是拆分它(这就是我认为它正在做的事情)?
谢谢
更新:已解决^^
跟进:
这可能与原始问题的思路相同:
我有一个变量,它是我想通过 cURL 发送的 JSON 输出。我假设问题再次是引号,但 JSON 输出可能会改变(引号数)。有没有办法在消息中用新行发送带有 cURL 的原始数据?谢谢
DUMPING RESULTS:\n{"result":{"id":"ppbkbz2ezmxen11vvpi65chsro1vki5y","zone_id":"unuM0sR1gSrQ37r9fGC1sYKFZOP0DzJM","zone_name":"demo.xyz","name":"1.demo.xyz","type":"A","content":"x.x.x.x","proxiable":true,"proxied":false,"ttl":1,"locked":false,"meta":{"auto_added":false,"managed_by_apps":false,"managed_by_argo_tunnel":false,"source":"primary"},"created_on":"2020-06-14T19:13:57.096688Z","modified_on":"2021-10-16T16:57:49.269274Z"},"success":true,"errors":[],"messages":[]}."