Posts Tagged ‘bash’

Latitude where am I 2 electric boogaloo!

Wednesday, February 3rd, 2010

I decided having it post to my blog wasnt just enough.  Why not track myself via google constantly.  below is the bash script i have running in cron minutely to record my coordinates.  Enjoy.

#!/bin/bash

#License GPLv3
ID=""
Points=/home/mog/docs/whereiam/points
cd $Points
if [ `ls .|wc -l` -eq 0 ]; then
wget -q "http://www.google.com/latitude/apps/badge/api?user=${ID}&type=json" -O new
mv new `date +%s`
else
File=`ls |tail -n1`
Last_Time_Stamp=`grep timeStamp $File|cut -f2 -d':'|cut -f1 -d','`
wget -q "http://www.google.com/latitude/apps/badge/api?user=${ID}&type=json" -O new
if grep -q $Last_Time_Stamp new ; then
rm new
else
mv new `date +%s`
fi
fi