在bash中以JSON格式打印字符串

时间:2016-11-25 06:51:29

标签: json linux bash fastcgi jq

我在我的CGI bash脚本中使用了以下语句,它返回错误[error] 1705#0: *105 upstream prematurely closed FastCGI stdout while reading response header from upstream [...]。这是一种正确的使用方法吗?

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

我的预期输出如下。

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

1 个答案:

答案 0 :(得分:0)

没有配置问题。导致该问题是因为POST请求的脚本没有响应。