Shashank Shashank - 7 days ago 6
JSON Question

Print a string in JSON format in bash

I am using below statement in my CGI bash scrip, which is returning me error

[error] 1705#0: *105 upstream prematurely closed FastCGI stdout while reading response header from upstream [...]
. Is this a correct way to use it?

echo "{\"meta\": {\"link\": {\"upload\": { \"href\": \"http://${ip}${target}\"}}}, \"status\": \"empty\"}" | jq .


My expected output is as below.

{
"meta": {
"link": {
"upload": { "href": "http://fileserver.example.com/upload/content/{id}" }
}
},"status": "empty"
}

Answer

There was no configuration issue. The problem was caused because there was no response from the script for the POST request.

Comments