Sorry for posting hard to read code. I think you can look at the one-liner code which was at the bottom of the first post, the rest was "just" explanation:
Command:
Code:
user@host:~$ snmpget -Oqv -v 2c -c $COMMUNITY $IP .1.3.6.1.2.1.2.2.1.7.5 .1.3.6.1.2.1.2.2.1.8.5 .1.3.6.1.2.1.2.2.1.5.5 .1.3.6.1.2.1.2.2.1.3.5 .1.3.6.1.2.1.2.2.1.6.5 .1.3.6.1.2.1.2.2.1.2.5
Output:
Code:
up
down
1000000000
ethernetCsmacd
Ethernet CPE Interface
Yes, all entries are coming out as one-per-line. And yes, it does output blank lines if the value is empty.
I already thank you a lot for your time and I think you are close nearby, but the blank line isn't handled as expected:
Command:
Code:
user@host:~$ IFS=$'\n' ifarray=( $(snmpget -Oqv -v 2c -c $COMMUNITY $IP .1.3.6.1.2.1.2.2.1.7.5 .1.3.6.1.2.1.2.2.1.8.5 .1.3.6.1.2.1.2.2.1.5.5 .1.3.6.1.2.1.2.2.1.3.5 .1.3.6.1.2.1.2.2.1.6.5 .1.3.6.1.2.1.2.2.1.2.5) ); echo =0=${ifarray[0]}=; echo =1=${ifarray[1]}=; echo =2=${ifarray[2]}=; echo =3=${ifarray[3]}=; echo =4=${ifarray[4]}=; echo =5=${ifarray[5]}=
Output:
Code:
=0=up=
=1=down=
=2=1000000000=
=3=ethernetCsmacd=
=4=Ethernet CPE Interface=
=5==
So it is assigning line 6 to array index 4 insted of 5 as expected.
Well, I could do simply after the my-command-to-get-the-values:
Or do you know here a better trick?
Once more: Many thx for your help.