shell - Passed command line argument in double quotes to curl -


my script taking command line argument , needs pass curl command in double quotes. simplified version of tried far:

json=$1; echo $json; 

curl -x post -d '{"asin":\"$json\", "template":"bolt","version":"1d"}' -h "content-type: application/json" http://someurl

but not working. please help

$-variables in single quoted strings don't expanded. -d argument needs in double quotes, or @ least $json part needs be:

curl -x post -d '{"asin":"'"$json"'", "template":"bolt","version":"1d"}' -h "content-type: application/json" http://someurl 

'-terminates single-quoted string, "$json" follows, , ' starts adjacent single quoted string.

the "$json" variable shouldn't expand string containing unescaped double quotes or resulting json broken.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -