Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What I want is this:

  • netcat to the server, which streams json formatted loglines.
  • pipe the output of nc to "something" that will format the json as plaintext, in a customizable format (thinking something like perl or python here).
  • allow "something" to be greppable.

My small attempts at piping the output of nc to something else leads to the server outputting "Broken pipe".

share|improve this question
What are you trying to accomplish? Would parsing the JSON be acceptable or do you prefer to grep? – tristan Mar 26 '13 at 11:28

I'd start looking at the python JSON processors, to start you can format it in "pretty" style simply:

| python -mjson.tool

and there are many people who have extended on that, here are a few examples.

share|improve this answer
This one worked really nice and would be a good starting point on formatting the output. As stated in another comment, the issue I'm having is something that I suspect has to do with nc. – c0dem4gnetic Mar 26 '13 at 17:00
Yeah, remember all JSON is not created equal. – NickW Mar 26 '13 at 17:01

I use jq to parse JSON on the command line. I'm aware that your question asks for something to render it in plaintext for grepping, but I think this is closer to what you're trying to accomplish.

For instance:

    "server_url": "http://localhost:4000"

Can be parsed to yield:

    tristan.local]$  ~  cat chef.json| jq -c '.run_list[]' 

Check out the tutorial, it's quite useful.

share|improve this answer
Neat tool! Although I suspect that this won't work with a nc pipe (see my edit) – c0dem4gnetic Mar 26 '13 at 16:58
Ah, track down why you're getting disconnected when trying to stream data first. – tristan Mar 26 '13 at 18:06

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.