[PLUG] shell scripting

Joe Pruett joey at clean.q7.com
Wed Oct 21 21:21:18 UTC 2009


> hello all,
>
> i want to Perform an SNMP set request in SNMP agent. return 0 if the
> connect succeeded.
>
> here is what i did :
>
> LIST = 'ypcat hosts|| sort | awk '{print $2}''
> for Devices in $LIST
> do
> Errorcount=`snmpget -v1 -c privator $Devices snmpInBadCommunityNames.O
> |awk '{print $4}' `
> if [ Errorcount > 0 ]; then
> Devices=$Errorcount
> echo $Devices
> # line added
> echo "$sysdate $Devices" >> /tmp/hosthistory.txt
>
> fi
> done
>
> but the answer is wrong cause i'm getting an errorcount.

well, rather than using awk, i'd suggest using the -Oqv option to snmpget. 
that will make it only spit out the value.

but i'm not sure what you are trying to do.  that snmpget will return the 
total number of bad requests the device has seen since reboot.  is that 
what you want to do?



More information about the PLUG mailing list