传递的参数不在 curl 命令中解释
Passed arguments are not interpreted in curl command
我有一个 shell 脚本,它只执行 curl 命令来通知我的 Discord 服务器有关问题。我传递了两个参数,我想将它们添加到 curl 命令的数据主体中,但它们的值未被解释。
我的脚本调用:
./notifier.sh usernameArg contentArg
我的脚本:
#!/bin/bash
curl -X POST -H "Content-Type: application/json" -d '{"username": "", "content": ""}' "https://<discord webhook url>"
但它发送的只是{"username": "", "content": ""}
。
我也尝试使用 ${1} 和 ${2} 得到相同的结果。
提前感谢您的帮助!
试试这个。
#!/bin/bash
curl -X POST -H "Content-Type: application/json" -d '{"username": "''", "content": "''"}' "https://<discord webhook url>"
我有一个 shell 脚本,它只执行 curl 命令来通知我的 Discord 服务器有关问题。我传递了两个参数,我想将它们添加到 curl 命令的数据主体中,但它们的值未被解释。
我的脚本调用:
./notifier.sh usernameArg contentArg
我的脚本:
#!/bin/bash
curl -X POST -H "Content-Type: application/json" -d '{"username": "", "content": ""}' "https://<discord webhook url>"
但它发送的只是{"username": "", "content": ""}
。
我也尝试使用 ${1} 和 ${2} 得到相同的结果。
提前感谢您的帮助!
试试这个。
#!/bin/bash
curl -X POST -H "Content-Type: application/json" -d '{"username": "''", "content": "''"}' "https://<discord webhook url>"