bash: escaping/anchoring args for wget
I use the following wget foo:
Code:
wget -qO - --no-check-certificate --header='Content-Type: text/plain' --header='Accept: text/plain' http://snoop.nsa.gov/snooplist.txt Code:
wget=/usr/local/bin/wget I have tried many variations here, enclosing the whole wget_args in ticks, using anchors (escaping) before each tick, and so on. Rather than illustrating all of my failed attempts can someone show me how this might be handled properly? |
Try placing the items in an array and calling it:
Code:
wget=/usr/local/bin/wget |
Grail --that's a smart approach but it still loses the ticks around the header values and as a result they are never passed to the server:
If I run with set -x + /usr/local/bin/wget -qO - --no-check-certificate --header=Content-Type: text/plain --header=Accept: text/plain http://snoop.nsa.gov/snooplist.txt |
So it is failing? Not sure if the address is made up, but it does not work for me copying it from your original post anyway.
|
The url I'm using is just a humorous example. What I'm actually using it against is an (internal access only) API that gives either JSON or TEXT responses based on the requested header. Unfortunately I can't find a site that behaves similarly that I could post here as an example.
Yet if you run the following you'll see how the first wget does not include ticks around the header values but the second one does. I've not yet found a means to maintain those header values... Code:
set -x Code:
+ wget=/usr/local/bin/wget |
Ok ... I was using a different method so missed what you needed initially, but what if you quote within the array:
Code:
wget_args=( -qO - --no-check-certificate "--header='Content-Type: text/plain'" "--header='Accept: text/plain'" ) |
All times are GMT -5. The time now is 05:14 PM. |