Created
December 8, 2009 00:59
-
-
Save nall/251327 to your computer and use it in GitHub Desktop.
Dump Garmin XML
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
my $date = `date "+%m%d%y"`; | |
chomp($date); | |
my $tmpfile = "/tmp/GRMN_".$date.".xml.tmp"; | |
my $file = "$ENV{HOME}/Documents/GRMN_logs/GRMN_".$date.".xml"; | |
print "Reading from GPS...\n"; | |
system("/Library/MotionBased/GpstoMb Xml=true GzipBase64=false > $tmpfile 2> /dev/null"); | |
open(FILE, "<$tmpfile") or die("Cannot open $tmpfile for reading"); | |
open(OUTFILE, ">$file") or die("Cannot open $file for writing"); | |
my $print = 0; | |
while(<FILE>) | |
{ | |
my $line = $_; | |
if($line =~ /^<\?xml version/) | |
{ | |
$print = 1; | |
} | |
print OUTFILE $line if $print == 1; | |
if($line =~ /^<\/TrainingCenterDatabase>/) | |
{ | |
$print = 0; | |
} | |
} | |
close(FILE); | |
close(OUTFILE); | |
unlink($tmpfile); | |
system("/usr/bin/gzip $file"); | |
print "Results in: $file.gz\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment