Hardware Reference
In-Depth Information
3.
Add the following script snippet:
#!/bin/bash
LAT=""
LONG=""
gpspipe -d -w -o /tmp/gpsdump
while ([ -z $LAT ] || [ -z $LONG ]) ; do
if [ -f /tmp/gpsdump ] ; then
LAT=$(cat /tmp/gpsdump | awk 'BEGIN{RS=","; FS=":"} /lat/
{save=$2} END {print save}')
LONG=$(cat /tmp/gpsdump | awk 'BEGIN{RS=","; FS=":"} /lon/
{save=$2} END {print save}')
fi
done
killall gpspipe
rm /tmp/gpsdump
echo "-lat=$LAT -long=$LONG"
Save and exit nano , then make the script executable with chmod +x ~/
passgps.sh .
The scripts launches a gpspipe session in the background, which will fill up
/tmp/gpsdump with data obtained from gpsd . We then enter a while loop
until we're able to filter out the latitude and longitude from /tmp/gpsdump
by using an awk command and we put the coordinates into the LAT and LONG
variables. Then we clean up a bit after our script and output the coordinates
on a line suitable for ttytter .
4.
Now, all we need to do is tweet something with -location added as an
argument to enable geotagging for this particular tweet, then let our script
pass in the GPS coordinates. Just remember that you need to have gpsd
running for our script to work.
pi@raspberrypi ~ $ ttytter -status="$(vcgencmd measure_temp)
today, feeling cozy" -location $(~/passgps.sh)
Tweet tagged with location obtained from GPS
 
Search WWH ::




Custom Search