Bash and snmpget
Thanks for even looking at this :)
I have a SNMP script that pull 3 OIDs from a device: Code:
snmpget -v 1 -Ovq -r 0 -c public 10.75.131.181 .1.3.6.1.4.1.11268.2.1.1.2.29.1.1.4.3.1 .1.3.6.1.4.1.11268.2.1.1.2.29.1.1.4.8.1 .1.3.6.1.4.1.11268.2.1.1.2.29.1.1.4.11.1 | sed -n '1h;2,$H;${g;s/\n/,/g;p}' >> test Quote:
Code:
# cat test Example : Code:
# cat test SeeFor |
I suspect that the error message is being written to /dev/stderr, and all you'd need to do is capture the message to a file (e.g., 2>/tmp/errors or the like), and then parse the error(s).
Note: Just guessing because nobody more knowledgeable than I has yet replied to your inquiry. |
Maybe after running the snmpget, the shell's status is set to a non-zero value to indicate an error; thus perhaps $? can be used. I'm not sure though if the sed will affect this value or not.
Code:
sed_res=`snmpget -v 1 -Ovq -r 0 -c public 10.75.131.181 .1.3.6.1.4.1.11268.2.1.1.2.29.1.1.4.3.1 .1.3.6.1.4.1.11268.2.1.1.2.29.1.1.4.8.1 .1.3.6.1.4.1.11268.2.1.1.2.29.1.1.4.11.1 | sed -n '1h;2,$H;${g;s/\n/,/g;p}'` |
All times are GMT -5. The time now is 12:06 AM. |