On 13/10/2020 11:12, Vladimír Čunát wrote:
Hello.
On 10/13/20 1:40 AM, pioruns2019(a)gmx.com wrote:
How can I have output these commands in shell
script?
It comes over the socket... so you can read it, but we recommend tojson
for scripts, e.g.:
output="$(echo "tojson(cache.stats())" | socat -
/run/knot-resolver/control/1)"
There's the inconvenience of "> " occurrences meant for interactive use
of the control socket, but it shouldn't be too hard to trim in the script.
--Vladimir
Thanks Vladimir!
That worked fantastically.
I used:
output="$(echo "tojson(cache.stats())" | socat -
/run/knot-resolver/control/1 | cut -c 3- | rev | cut -c 1- | rev)"
echo $output | jq .
And it parses everything beautifully. I can now implement things into my
bots.
Kind regards,
Piotr