Created
September 3, 2018 19:30
-
-
Save tallakt/c8dc21463a3ff133c858a54f4b283c9f to your computer and use it in GitHub Desktop.
This file contains 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 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