bash:
response=$(curl -s 'http://nc8q-hap-ac3/cgi-bin/sysinfo.json')
node=$(echo "$response" | jq '.node')
echo "The node is $node"
Returns:
The node is "NC8Q-HAP-AC3"
-----
response=$(curl -s 'http://nc8q-hap-ac3/cgi-bin/sysinfo.json?link_info=1')
echo $response
value=$(echo "$response" | jq '.hostname')
echo "The hostname is $value"
Returns:
<...bunch of stuff...>
The hostname is null
There are many "hostname": "<hostname>" pairs in $response.
How do I parse them?
73, Chuck
response=$(curl -s 'http://nc8q-hap-ac3/cgi-bin/sysinfo.json')
node=$(echo "$response" | jq '.node')
echo "The node is $node"
Returns:
The node is "NC8Q-HAP-AC3"
-----
response=$(curl -s 'http://nc8q-hap-ac3/cgi-bin/sysinfo.json?link_info=1')
echo $response
value=$(echo "$response" | jq '.hostname')
echo "The hostname is $value"
Returns:
<...bunch of stuff...>
The hostname is null
There are many "hostname": "<hostname>" pairs in $response.
How do I parse them?
73, Chuck
Try the attached script. Credit goes to AI, but I was the manager. :)
It works nicely for me.
The extension was just to make it uploadable.
- Mike AB4YY
Also, on my localnode, I see my own host names but when I run it against another system on the mesh, I do not see any host names. But maybe the script can still be of some use.
This may be required: sudo apt install jq
- Mike
Thank you.
I have tried your script. kewel!
I need to understand the syntax to read nested key:value pairs.
73, Chuck