kristopolous / TickTick

JSON in your Bash scripts

Home Page:http://9ol.es/TheEmperorsNewClothes.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Read json data from standard input or pipe ?

phillipkent opened this issue · comments

Maybe this is obvious but I'm a novice with shell scripts...

Can I use TickTick to take json data from standard input - or (which is equivalent I think) pipe output into a TickTick-based script ?

Assume the json data is well-formed and don't need to check it for validity.

Thank you for a nice project.

You can read input with the 'read' built in command into a variable or a temporary file. Then you can use the tickParse routine to deal with it.

If you need further elaboration, please include some existing attempts you've made in a follow-up email so I can more specifically address your concern.

Thanks.

Phillip Kent notifications@github.com wrote:

Maybe this is obvious but I'm a novice with shell scripts...

Can I use TickTick to take json data from standard input - or (which is equivalent I think) pipe output into a TickTick-based script ?

Assume the json data is well-formed and don't need to check it for validity.

Thank you for a nice project.


Reply to this email directly or view it on GitHub.

Hello Kris, I got it working using:

DATA=$(cat)
tickParse "$DATA"

That works well. It was hard to find documentation about using $(cat) in bash. Are there reasons why it shouldn't be used? A problem I am getting now is that my JSON object seems to parse correctly (looking at the tickVars output) but the .length() and .items() methods don't do what I expect.

See example JSON here: https://gist.github.com/phillipkent/1cbd830d7412c04076fc/download

I expect virtualmachines.length() = 12 but it returns 597. And virtualmachines.items() seems to be empty.

Thanks again for useful code. My final program is here: https://gist.github.com/InterouteGIST/ca5040051bb70ac6a0d4

Ok great. Glad i could help!