Ich habe dieses Linux Script zum Abfragen einer API mit Curl.
path="$1"
curl -k -L "https://<fw-ip>:4444/api/$path" \
-H "Authorization: Basic xxxxxxxxxx"
Das Ergebnis der Abfrage ist immer ein JSON Objekt wie z.B
[
{
"_locked": "",
"_ref": "REF_IntEthPresentati",
"_type": "interface/ethernet",
"additional_addresses": [],
"bandwidth": 0,
"comment": "",
"inbandwidth": 0,
"itfhw": "REF_ItfEthEth6IntelCorpo",
"link": true,
"mtu": 1500,
"mtu_auto_discovery": true,
"name": "presentation",
"outbandwidth": 0,
"primary_address": "REF_ItfPri1722130124",
"proxyarp": false,
"proxyndp": false,
"status": false
},
{
"_locked": "",
"_ref": "REF_IntEthLogeaudio",
"_type": "interface/ethernet",
"additional_addresses": [],
"bandwidth": 0,
"comment": "Sonos Boxen Loge",
"inbandwidth": 0,
"itfhw": "REF_ItfAweLogeaudio",
"link": true,
"mtu": 1500,
"mtu_auto_discovery": true,
"name": "Loge_Audio",
"outbandwidth": 0,
"primary_address": "REF_ItfPri1721629124",
"proxyarp": false,
"proxyndp": false,
"status": true
},
{
"_locked": "",
"_ref": "REF_IntEthScantest",
"_type": "interface/ethernet",
"additional_addresses": [],
"bandwidth": 0,
"comment": "ScanTest",
"inbandwidth": 0,
"itfhw": "",
"link": true,
"mtu": 1500,
"mtu_auto_discovery": true,
"name": "ScanTest",
"outbandwidth": 0,
"primary_address": "REF_ItfPri109998124",
"proxyarp": false,
"proxyndp": false,
"status": false
},
{
"_locked": "",
"_ref": "REF_IntEthResponsive",
"_type": "interface/ethernet",
"additional_addresses": [],
"bandwidth": 0,
"comment": "",
"inbandwidth": 0,
"itfhw": "",
"link": true,
"mtu": 1500,
"mtu_auto_discovery": true,
"name": "ResponsiveTest",
"outbandwidth": 0,
"primary_address": "REF_ItfPri109999124",
"proxyarp": false,
"proxyndp": false,
"status": false
},
{
"_locked": "",
"_ref": "REF_IntEthTest",
"_type": "interface/ethernet",
"additional_addresses": [
"REF_ItfSecOldinterna"
],
"bandwidth": 0,
"comment": "",
"inbandwidth": 0,
"itfhw": "REF_ItfEthEth5IntelCorpo",
"link": true,
"mtu": 1500,
"mtu_auto_discovery": true,
"name": "Fortinet",
"outbandwidth": 0,
"primary_address": "REF_ItfPri1722302512",
"proxyarp": false,
"proxyndp": false,
"status": true
},
{
"_locked": "",
"_ref": "REF_IntEthWirelGuestNetwo",
"_type": "interface/ethernet",
"additional_addresses": [],
"bandwidth": 0,
"comment": "Auto-created by Wireless Protection",
"inbandwidth": 0,
"itfhw": "REF_ItfAweWlan0WirelNetwo",
"link": true,
"mtu": 1500,
"mtu_auto_discovery": true,
"name": "Wireless Guest Network",
"outbandwidth": 0,
"primary_address": "REF_ItfPriWirelGuestNetwo",
"proxyarp": false,
"proxyndp": false,
"status": true
}
]
Gibt es eine Möglichkeit in Linux bestimmte Werte davon anzuzeigen? Ich möchte z.B von jedem Objekt im Array (jedes Interface) den Namen (name) und die Referenz auf die IP (primary_address) anzeigen. So wie in diesem Pseudo Code?
sh api.sh objects/interface/ethernet | foreach | select name, primary_address