webservice webservice - 3 years ago 222
JSON Question

json curl to varible in bash

I have a CURL on my sh script.
I need save it`s ddecoded ata.

curl -H "Content-Type: application/json" -X POST -d '{"hash":"$restearterHash"}' {$host}ApiController/jsonRestarter/ | python -m json.tool

how to save data in the varible?

Answer Source

You could use command substitution:

VAR=$(curl -H "Content-Type: application/json" -X POST -d '{"hash":"$restearterHash"}' {$host}ApiController/jsonRestarter/ | python -m json.tool)
echo "${VAR}"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download