#!/bin/sh

# getloc <mac address> <essid>
# getloc "01:23:45:67:89" "mynet"

TMPFILE=getloc-$$

cat > /tmp/$TMPFILE <<EOF
POST /loc/json HTTP/1.1
Host: www.google.com
User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.9.0.10) Gecko/2009042523 Ubuntu/9.04 (jaunty) Firefox/3.0.10 GTB5
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Content-Type: application/json
Cache-Control: no-cache, no-cache
Pragma: no-cache, no-cache
Content-Length: 242

{ "access_token" : "2:M1YgFR8hFPIvgjKC:D5jukmZyeTW0t3ZR", "host" : "code.google.com", "radio_type" : "unknown", "request_address" : true, "version" : "1.1.0", "wifi_towers" : [ { "mac_address" : "$1", "ssid" : "$2" } ] }



EOF

(cat /tmp/$TMPFILE ; sleep 1; echo "") | nc www.google.com 80 |grep latitude

echo

rm /tmp/$TMPFILE
