I have a bash script that does a curl request for a URL. All curl headers and information is contained in a variable, here is a simplified example
STRING="'http://www.mydomain.com/url' -H 'mydomain.com'"
I originally had the script working by doing echo and xargs to pass it, but I've been reading that it might not be a good way to do things
I ran into issues when just trying curl $STRING
, and adding double quotes to make it curl "$STRING"
now gives a curl error stating "curl: (1) Protocol "'http" not supported or disabled in libcurl"
I'm guessing there is some simple thing I am overlooking here possibly relating to the quotes and spaces (I tried escaping single quotes earlier and that just added them literally in the string)
If I echo $STRING it displays it as written with all quotes and single quotes, and doing echo $STRING | xargs curl
does what I want correctly, it does curl with my string as it's input
'http://www.mydomain.com/url' -H 'mydomain.com'
If I do
– Kate N Feb 14 '17 at 20:56echo $STRING | xargs curl
it works perfectly that way