diff options
Diffstat (limited to 'contrib/gpxlogger.pl')
-rwxr-xr-x | contrib/gpxlogger.pl | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/contrib/gpxlogger.pl b/contrib/gpxlogger.pl index 5d6153d9..f60ec5c2 100755 --- a/contrib/gpxlogger.pl +++ b/contrib/gpxlogger.pl @@ -36,6 +36,13 @@ getopts ("hi:p:s:vw:", \%opt); usage() if (defined($opt{'h'})); check_options(); +open($out, ">" . $opt{'w'}) or die "Can't open $opt{'w'}: $!\n"; +select((select($out), $| = 1)[0]); +write_header(); + +$SIG{'TERM'} = $SIG{'QUIT'} = $SIG{'HUP'} = $SIG{'INT'} = \&cleanup; + +while (1){ #connect print "Connecting to $opt{'s'}:$opt{'p'}" if ($opt{'v'}); $sock = IO::Socket::INET->new(PeerAddr => $opt{'s'}, @@ -45,12 +52,6 @@ $sock = IO::Socket::INET->new(PeerAddr => $opt{'s'}, or die "\nCouldn't connect to $opt{'s'}:$opt{'p'} - $@\n"; print " OK!\n" if ($opt{'v'}); -open($out, ">" . $opt{'w'}) or die "Can't open $opt{'w'}: $!\n"; -select((select($out), $| = 1)[0]); -write_header(); - -$SIG{'TERM'} = $SIG{'QUIT'} = $SIG{'HUP'} = $SIG{'INT'} = \&cleanup; - print $sock "MSQO\n"; while (defined( $line = <$sock> )){ chomp $line; @@ -72,7 +73,8 @@ while (defined( $line = <$sock> )){ sleep($opt{'i'}); print $sock "MSQO\n"; } - +sleep(1); +} cleanup("PIPE"); ########################################################################### |