Skip to content

Instantly share code, notes, and snippets.

@mendelgusmao
Created April 14, 2015 21:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mendelgusmao/46fef16df4ec2d8e1ec1 to your computer and use it in GitHub Desktop.
Save mendelgusmao/46fef16df4ec2d8e1ec1 to your computer and use it in GitHub Desktop.
cache=/var/db/vwash.cache
touch $cache
while read line; do
mac=$(echo "$line" | cut -d: -f1-3)
if echo $mac | grep -i -e '[a-f0-9]\{2\}:' > /dev/null; then
lookup=$(grep "$mac=" $cache)
if [ $? -gt 0 ]; then
lookup=$(wget -qO- http://www.macvendorlookup.com/api/v2/$mac/pipe)
vendor=$(echo $lookup | cut -d\| -f5 | cut -d\ -f1 | cut -c1-10 | sed s/[^a-zA-Z\s]//g)
echo "$mac=$vendor" >> $cache
else
vendor=$(echo $lookup | cut -d= -f2)
fi
printf "%0-17s%s\n" "$vendor" "$line"
else
if echo $line | grep ^BSSID > /dev/null; then
echo "Vendor $line"
else
echo "$line"
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment