Skip to content

Instantly share code, notes, and snippets.

@Niek
Created December 28, 2010 10:16
Show Gist options
  • Save Niek/757112 to your computer and use it in GitHub Desktop.
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)
/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
@Niek
Copy link
Author

Niek commented Dec 28, 2010

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment