I'm trying to get an SNMP walk into an array, the data in the variable is in the format "data1 data2" "data3 data4". Essentially I just want the data between the double quotes, regardless of how many spaces there may be.
I've been googleing for about an hour and a half and cannot figure out how to get the array correctly formatted.
Here is a snippit of the code that I have right now...
IN=$(snmpwalk -Oqv -v2c -c$community $ipaddr .1.3.6.1.4.1.32050.2.1.26.2)
portdesc=($(echo $IN))
This does put it in an array, but when trying to access the first data set I get "data1 instead of "data1 data2". I can cheat and just use two variables but I'd rather do it the right way and just reference the array for the item that I want.
If you can help me with this I will be eternally greatfull.
echo "DEBUG0: ${portdesc[@]}"
echo "DEBUG1: ${portdesc[0]}"
DEBUG0: "Relay Output" "Expansion Power" "Expansion Tripped" "Switch Input" "Radio 1 Power" "Radio 2 Power" "Radio 3 Power" "Radio 4 Power" "Radio 1 Sync" "Radio 2 Sync" "Radio 3 Sync" "Radio 4 Sync" "Radio 1 Tripped" "Radio 2 Tripped" "Radio 3 Tripped" "Radio 4 Tripped" "SyncPipe Power" "SyncPipe Tripped" "Switch to NMEA" "2D Fix" "3D Fix" "DGPS Fix" "1PPS Active" "Radio 1 Power" "Radio 2 Power" "Radio 3 Power" "Radio 4 Power" "Radio 1 Sync" "Radio 2 Sync" "Radio 3 Sync" "Radio 4 Sync" "Radio 1 Tripped" "Radio 2 Tripped" "Radio 3 Tripped" "Radio 4 Tripped" "SyncPipe Power" "SyncPipe Tripped" "Switch to NMEA" "2D Fix" "3D Fix" "DGPS Fix" "1PPS Active" "Radio 1 Power" "Radio 2 Power" "Radio 3 Power" "Radio 4 Power" "Radio 1 Sync" "Radio 2 Sync" "Radio 3 Sync" "Radio 4 Sync" "Radio 1 Tripped" "Radio 2 Tripped" "Radio 3 Tripped" "Radio 4 Tripped" "SyncPipe Power" "SyncPipe Tripped" "Switch to NMEA" "2D Fix" "3D Fix" "DGPS Fix" "1PPS Active"
DEBUG1: "Relay
SNMP COMMAND FROM CLI
$ snmpwalk -O qv -v2c -c<community> <ip> .1.3.6.1.4.1.32050.2.1.26.2
"Relay Output"
"Expansion Power"
"Expansion Tripped"
"Switch Input"
"Radio 1 Power"
"Radio 2 Power"
"Radio 3 Power"
"Radio 4 Power"
"Radio 1 Sync"
"Radio 2 Sync"
"Radio 3 Sync"
"Radio 4 Sync"
"Radio 1 Tripped"
"Radio 2 Tripped"