Hi all I have been mucking around with a (very rough) bash script for a couple of days which I'm using to download the current real-time location from a Holux GPS data logger
I'm using GPSBabel to capture and filter NMEA data via gpsd over bluetooth and it's working fine It is reducing the waypoint data to a generic "WPT001" What I want to do now is rename the name field to a time stamped 6 character waypoint name eg. "WP1245" (<<1345Hrs) & I thought sed was just the command for the job & created file name like: "WP1345.gpx" (has to be .gpx to re-import into my mapping software running on wine) The output gpx file looks like this: <?xml version="1.0" encoding="UTF-8"?> <gpx version="1.0" creator="GPSBabel - http://www.gpsbabel.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.topografix.com/GPX/1/0" xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd"> <time>2008-08-06T23:57:56Z</time> <bounds minlat="-43.571090000" minlon="172.689703333" maxlat="-43.571090000" maxlon="172.689703333"/> <wpt lat="-43.571090000" lon="172.689703333"> <ele>-2.800000</ele> <time>2008-08-06T23:57:50Z</time> <name>WPT001</name> <cmt>WPT001</cmt> <desc>WPT001</desc> <fix>dgps</fix> <sat>9</sat> <hdop>0.930000</hdop> <vdop>1.380000</vdop> <pdop>1.660000</pdop> </wpt> </gpx> My intention is to rename the <name> field and copy the time stamp data (converted to local time from UTC) to the <cmt> field if poss My (draft) script: #!/bin/sh # ------------------------------------------------------------------------ # # rough script to start gpsd & and download/convert current location to # a single waypoint named: "WP<current_time>" (eg. WP1345) WPTF=WP`date +%y%m%d-%H%M`.gpx WPTN=WP`date +%H%M` LOC=~/tmp/test GCF=~/tmp/test/GPS WPTD=gpsd.dump WPTX=gpsd.gpx WPTY=YouAreHere.gpx # filter the .gpx data and remove duplicates by location, shortname # remove duplicates if within 10m, and delete source file OPTS="-x transform,wpt=trk,del -x duplicate,location,shortname -x position,distance=10m,del" echo "" gpsd -b /dev/rfcomm4 & echo " 1. Starting gpsd over bluetooth" & sleep 2 echo " ... please wait" & sleep 2 echo "" echo rw | nc localhost 2947 > $LOC/$WPTD & echo " 2. Downloading current location from Holux" & sleep 3 echo " ... please wait" & sleep 3 echo "" & ## run gpsbable to filter data & reduce it to one waypoint: gpsbabel -i nmea -f $LOC/$WPTD $OPTS -o gpx -F $LOC/$WPTF & echo " 3. Current location saved to file $LOC/$WPTF" && echo "" & rm $GCF/$WPTY && ## then use sed to replace the generic WP name: (STILL NOT WORKING) sed 's/WPT001/$WPTN/' $LOC/$WPTF > $GCF/$WPTY killall -q gpsd >/dev/null & rm $LOC/$WPTD & exit 0 When I run my script however I get sed syntax errors, I have done alot of googling annd read the sed/awk man pages but I can't get my head around the problem It appears to work fine with manually entered values but errors with the "$WPTN" (or $DATE) values in the second field I have tried several values and switches without much luck cheers .................dave
