You are here

sysinfo.json: The hostname is null.

4 posts / 0 new
Last post
nc8q
nc8q's picture
sysinfo.json: The hostname is null.
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
AB4YY
Chuck,
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
File Attachment: 
AB4YY
The script returns lots of
The script returns lots of stuff in human readable form.  On mine, I commented out the JSON return to only get the easy to read stuff.
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
nc8q
nc8q's picture
sysinfo.json and jq
Hi, Mike:

Thank you.
I have tried your script. kewel!
I need to understand the syntax to read nested key:value pairs.

73, Chuck
 

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer