#!/bin/sh # Author: Robert Harder, rob _ iharder.net # Web: http://blog.iharder.net # Date: November 2010 # License: Public Domain # Example: # <+37.19511210, -120.37831060> +/- 150.00m (speed 0.00 mps / course -1.00) @ 2010-10-22 11:10:09 -0700 PATH=/usr/local/bin:$PATH LOCATION=$(LocateMe) # Parse Lat and Lon LAT=$(echo $LOCATION | sed 's/<\([0-9+-\.]*\), \([0-9+-\.]*\)> \(+\/- [0-9a-zA-Z\.]*\) (.*/\1/' ) LON=$(echo $LOCATION | sed 's/<\([0-9+-\.]*\), \([0-9+-\.]*\)> \(+\/- [0-9a-zA-Z\.]*\) (.*/\2/' ) ERR=$(echo $LOCATION | sed 's/<\([0-9+-\.]*\), \([0-9+-\.]*\)> \(+\/- [0-9a-zA-Z\.]*\) (.*/\3/' ) # Log location right away logger -t "$(basename $0)" "$LOCATION" # Network Up? function netup(){ NETUP=$(osascript - << EOF try do shell script "ping -c 1 api.notifo.com" do shell script "echo Y" on error do shell script "echo N" end try EOF ) echo $NETUP } # Wait for network to be up while [ "$(netup)" == "N" ]; do logger -t $(basename $0) Waiting for network to come up to report location $LOCATION sleep 1 done # Get my external IP address MYIP="$(curl -s http://whatismyip.org/)" # Build a URL that will display a Google Maps page with useful info URL="http://maps.google.com/maps?q=${LAT},${LON}($(hostname),+${MYIP},+$(echo $ERR | urlencode),+$(date | urlencode))&ie=UTF8&ll=${LAT},${LON}&t=roadmap&z=14&iwloc=A&mrt=loc" # Log locally as well as calling notifo (another script) # and logging its response. logger -t "$(basename $0)" "$URL" logger -t "$(basename $0)" $(notifo.sh -l "$(hostname)" -t "Current Location" -u "$URL" $LOCATION)