linux - 如何在 cURL 的 URL 开头绑定(bind)变量,这是抛出错误

标签 linux bash shell curl sh

curl \ -H "Content-Type: application/json" \ -X POST \ $REPOSITORY_URL/engine-rest

http://10.195.177.141:31406 绑定(bind)到 REPOSITORY_URL

curl: no URL specified! curl: try 'curl --help' or 'curl --manual' for more information

我也试过给双引号

最佳答案

TL;DR:删除 \ 并重试。

试试这个:

curl  -H "Content-Type: application/json"  -X POST  $REPOSITORY_URL/engine-rest

对我来说,命令行中的 \ 字符似乎是多余的。他们告诉 bash 将空格视为参数值的一部分而不是分隔符。考虑到这一点,您传递给 curl 的第一个参数是“-H”(即:space:-H)。由于此参数不以 - 开头,因此程序假定它是 URL。 curl 在 -H 上执行 DNS 查找,但无法解析该主机名:

curl: (6) Could not resolve host:  -H

我怀疑我的错误与您不同的原因是因为我在 MacOS 上使用 curl。

关于linux - 如何在 cURL 的 URL 开头绑定(bind)变量,这是抛出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56368837/

相关文章:

c++ - 如何直接从Google Map批量下载大量高分辨率卫星图片?

shell - 尝试在 mac 上运行命令时出现 fish 错误

python - 如何从html调用python程序

Linux 配置/制作,--前缀?

linux - make工具中的变量声明

python - Bash 与 Python 中视觉相似字符串的 SHA256 有所不同

linux - ssh 连接在 Raspberry Pi 上被拒绝

linux - 在 bash 文件中转义变量

bash - Bash 中的 while 循环子 shell 困境

mongodb - 引用错误 : require is not defined in MongoDB shell