-ping -q -c 1 $host
-mac=`sudo arp -a | grep $host | cut -d' ' -f4 | sort -u`
-grep -r -i $mac /dev/shm/snmp-mac-port/ | tee /dev/shm/port.$host | egrep -v '(23|24|48|49)$' # remove trunk ports
+ping -c 1 $host | grep from > /dev/shm/port.$host.ping
+ip=`cat /dev/shm/port.$host.ping | cut -d' ' -f5 | tr -d '()':`
+host=`cat /dev/shm/port.$host.ping | cut -d' ' -f4`
+mac=`sudo arp -a -n | grep "($ip)" | cut -d' ' -f4 | sort -u`
+grep -r -i $mac /dev/shm/snmp-mac-port/ | tee /dev/shm/port.$host.switch | cut -d: -f2- | egrep -v '(23|24|48|49)$' # remove trunk ports