shell - 带有 curl 命令的 Shell 代码抛出格式错误的错误
问题描述
我有一个 curl 命令:
list_groups=$(curl -u GET "${name_host}/groups/listeridentifier")
echo "${list_groups}"
它返回一个错误:
curl: (3) <url> malformed
我只试过 Echo :
echo " result1 $(curl -u GET "${name_host}/groups/listeridentifier") result2"
总是返回相同的错误:
curl: (3) <url> malformed
result 1 result2
参数 name_host 为:
http://host_name:number_port
知道当我在 API REST (HttpRequest) 中执行它时它运行良好,我只更改了主机的名称和 ssh 中的端口号。仅在我的 shell 代码中。
谁能告诉我问题出在哪里?
解决方案
如果您正在使用,-u
那么 curl 将期待您想要充当的用户的参数。
curl --help
...
-u --user USER[:PASSWORD] Server user and password
...
推荐阅读
- html - 使用 CSS 对齐图标和文本
- python - 如何干净利落地睡不着?
- javascript - $inc 查询的 Nodejs 和 Mongoose 渲染路径
- wordpress - 如何在 woocommerce 上从购物车中删除产品?
- oracle - JPA 中是否有与 INSTR Oracle 函数等效的函数
- c# - 获取特定语言的 CMD 输出,无论 Windows 上安装的语言如何
- r - 如何检查树是分类树还是回归树
- java - JSOUP - 未从元素中删除的元素
- ios - 从初始屏幕多次转换到具有 GMSMapView 的地图屏幕后应用程序崩溃
- c++ - 无法在 OS X 上将 OpenSSL 库与 Mingw 正确链接