Created
December 28, 2010 10:16
-
-
Save Niek/757112 to your computer and use it in GitHub Desktop.
Get your physical location based on the MAC address of your WiFi access point (Mac OS X only)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | grep BSSID | awk '{print $2}' | sed "s/^\(.\):/0\1:/" | sed "s/:\(.\):/:0\1:/g" | sed "s/:\(.\):/:0\1:/g" | sed "s/:\(.\)$/:0\1/" | xargs -I{} echo 'curl -s http://www.google.com/loc/json -d '\''{"version":"1.1.0","request_address":true,"wifi_towers": [{"mac_address":"{}"}]}'\'' | awk -F\" '\''{print "{} = "$32" "$36", "$28", "$12}'\''' | $SHELL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This one-liner uses/emulates the Google Gears API. Something similar could be done by using the Apple implementation of BSSID detection, which does a POST to http://mac-services.apple.com/clls/sloc. The format of the POST request and response is unclear to me though.