Skip to content

Instantly share code, notes, and snippets.

@tallakt
Created September 3, 2018 19:30
Show Gist options
  • Save tallakt/c8dc21463a3ff133c858a54f4b283c9f to your computer and use it in GitHub Desktop.
Save tallakt/c8dc21463a3ff133c858a54f4b283c9f to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'pty'
loop do
begin
PTY.spawn( "/usr/bin/gpspipe -w" ) do |stdout, stdin, pid|
stdout.each do |line|
m = line.match /"time":"(2...-..-..T..:..:......Z)"/
if m
puts %x(date -s #{m[1]})
exit(0);
end
end
end
rescue
# ok
end
sleep 5000
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment