#!/bin/ksh
# assuming snmpget returns non-zero when printer not running snmp
echo "These ip addresses are not running snmp on " `date` > nosnmp.log
while read ipaddr
do
snmpget -v 1 -c public $ipaddr sysName.0
if [ $? -ne 0 ]; then
echo "$ipaddr" >> nosnmp.log
fi
done < iplist.txt
but instead of just snmpget why don't you do a ping with a timeout first so you don't have to wait forever for each ip address ... i've modified jim's code below using a 5 second timeout on ping and taking out the "Timeout:" error ...
#!/bin/ksh
# assuming snmpget returns non-zero when printer not running snmp
echo "These ip addresses are not running snmp on " `date` > nosnmp.log
while read ipaddr
do
ping $ipaddr 5 > /dev/null 2>&1
if [ $? -eq 0 ]
then
snmpget -v 1 -c public $ipaddr sysName.0 2> /dev/null
if [ $? -ne 0 ];
then
echo "$ipaddr" >> nosnmp.log
fi
else
echo "$ipaddr" >> nosnmp.log
fi
done < iplist.txt
or else you can simply do ... since an unpingable networked printer is technically off the network functionwise ... (assuming a 2 second ping timeout) ...
#! /bin/ksh
echo "These ip addresses are unpingable as of [ `date` ]\n" > noping.log
for ipaddr in `< iplist.txt`
do
ping $ipaddr 2 2> /dev/null
if [ $? -ne 0 ]
then
echo "$ipaddr" >> noping.log
fi
done
exit 0