I am trying to get an SNMP transition to an array, the data in the variable is in the format "data1 data2"
"data3 data4"
. Essentially, I just need the data between double quotes, no matter how many spaces there may be.
I worked for about an hour and a half and cannot figure out how to format the array correctly.
Here is a piece of 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 puts it in an array, but when I try to access the first data set, I get "data1
instead of "data1 data2"
. "data1 data2"
I can trick and just use two variables, but I would rather do it right and just reference the array for the element that I I want, if you can help me, I will be forever magnificent.
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"
Chris
source share