#/usr/bin/env ruby # nistslurp.rb: get rhymes from time.nist.gov:78 as per # http://faktory.org/m/blog/archives/2005/04/04/strange-ntp-services/ # and collect timestamped responses in a file. # This version by Charlie "Vruba" Loyd , # 5 April 2005, and hereby released into the public domain. require 'date' require 'net/telnet' n = 100 port = 78 out = open("rhymes", "w+") n.times do out.print DateTime::now(), "\n" t = Net::Telnet::new({ "Host" => "time.nist.gov", "Port" => port, }) t.cmd("\n"){|l| out.print(l)} out.print DateTime::now(), "\n\n" out.flush() sleep(1) end # P.s.: I know they mostly don't rhyme, but I think they # still qualify as 'nursery rhymes', and what else are you gonna # call them?