1

I have this bash file

#!/bin/bash
while read LINE; do
  curl $LINE
  echo " $LINE"
done < $1

and the URLs are like this:

-v -X POST -H "Content-Type: application/json" -d '{"id": 1, "method": "something", "params": ["en", "1", "bob", "password"]}' https://HTTPAUTHUSER:HTTPAUTHPASS@someurl.com

But it seems like curl is getting

[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

I feel like I'm missing something really obvious. Any thoughts?

EDIT:

from comments below I added set -x and I see this

curl 'MYARGS'

when i have

curl "$LINE"

remove the quotes -> curl $LINE

change the curl command like this:

curl -v -X POST -H '"Content-Type:' 'application/json"' -d ''\''{"id":' 1, '"method":' '"something",' '"params":' '["en",' '"1",' '"bob",' '"password"]}'\''' https://HTTPAUTHUSER:HTTPAUTHPASS@someurl.com
Zombo
  • 1
  • 62
  • 391
  • 407
cbrulak
  • 15,436
  • 20
  • 61
  • 101

0 Answers0