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 -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -