我有这个bash文件
#!/bin/bash
while read LINE; do
curl $LINE
echo " $LINE"
done < $1
,网址如下:
-v -X POST -H "Content-Type: application/json" -d '{"id": 1, "method": "something", "params": ["en", "1", "bob", "password"]}' https://HTTPAUTHUSER:HTTPAUTHPASS@someurl.com
但似乎卷曲正在变得
[11:35]:sh loop.sh tmp.txt
* Hostname was NOT found in DNS cache
* Could not resolve host: application
* Closing connection 0
curl: (6) Could not resolve host: application
* Rebuilt URL to: 1,/
* Hostname was NOT found in DNS cache
* Could not resolve host: 1,
* Closing connection 1
curl: (6) Could not resolve host: 1,
* Rebuilt URL to: "method":/
* Hostname was NOT found in DNS cache
* Could not resolve host: "method"
* Closing connection 2
curl: (6) Could not resolve host: "method"
* Rebuilt URL to: "something",/
* Hostname was NOT found in DNS cache
* Could not resolve host: "something",
* Closing connection 3
curl: (6) Could not resolve host: "something",
* Rebuilt URL to: "params":/
* Hostname was NOT found in DNS cache
我觉得我错过了一些非常明显的东西。有什么想法吗?
编辑:
从下面的评论我添加了set -x,我看到了这个
curl 'MYARGS'
当我有
时curl "$LINE"
删除引号 - &gt; curl $LINE
更改curl命令,如下所示:
curl -v -X POST -H '"Content-Type:' 'application/json"' -d ''\''{"id":' 1, '"method":' '"something",' '"params":' '["en",' '"1",' '"bob",' '"password"]}'\''' https://HTTPAUTHUSER:HTTPAUTHPASS@someurl.com
答案 0 :(得分:2)
将输入文件格式化为:
url https://HTTPAUTHUSER:HTTPAUTHPASS@someurl.com
request POST
header 'Content-Type: application/json'
data '{"id": 1, "method": "something", "params": ["en", "1", "bob", "password"]}'
然后像这样跑:
curl --config tmp.txt