Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 119cb0d962
Fetching contributors…

Cannot retrieve contributors at this time

executable file 38 lines (30 sloc) 0.67 kb
#!/bin/gawk -f
function getcoord(string, a) {
split(string, a, ":")
gsub(/\"/, "", a[2])
return a[2]
}
function httpget() {
host = "geoiplookup.wikimedia.org"
socket = "/inet/tcp/0/" host "/80"
printf "GET / HTTP/1.1\r\nHost: %s\n\n", host |& socket
for (header in headers) {
printf "%s\r\n", headers[header] |& socket
}
printf "\r\n" |& socket
NR = 0
in_body = 0
while (socket |& getline) {
if (/^\r$/) {
socket |& getline
return $0
}
}
}
BEGIN {
data = httpget()
split(data, coords, /,/)
lat = getcoord(coords[3])
lon = getcoord(coords[4])
printf "http://maps.google.com/maps?q=%s,%s\n", lat, lon
}
Jump to Line
Something went wrong with that request. Please try again.