kernelsmith
2/7/2014 - 12:09 AM

mubix.rb

def checkit(arr3)
  if arr3.first =~ /uid=/
    print arr3.first.strip.split('modbusconfig=')[1].split(',')[0]
    print ':'
    print arr3[1].split(' ')[1]
    print ':'
    print arr3[2].split(' ')[1]
    print "\r\n"
  end
end

f = File.open(filename, 'r')

trifecta = []
while true
  line = f.readline
  break if line == File.eof # you may have to rescue an eof err instead, can't remember
  if trifecta.length < 4
    trifecta << line
    next
  end
  checkit(trifecta)
  trifecta.shift
end
 
f.close