- Author
-
Martin Carpenter
-
mcarpenter@free.fr
- Copyright
-
Copyright © Martin Carpenter 2013
The solaris-lastlog gem helps with the reading and writing of Solaris binary lastlog(4) files.
See the examples subdirectory.
require 'solaris/lastlog' io = File.open('/var/adm/lastlog', 'r') reader = Solaris::Lastlog.new(:endian => :little) uid = 0 while !io.eof? do record = reader.read(io) unless record.ll_time.zero? time = Time.at(record.ll_time) puts "%-5s %s %-16s %-8s" % [uid, time, record.ll_host, record.ll_line] end uid += 1 end
require 'solaris/lastlog' io = File.open('/var/adm/lastlog', 'r') reader = Solaris::Lastlog.new(:endian => :little) first_record = true while !io.eof? do record = reader.read(io) if first_record first_record = false record.ll_time = Time.now.to_i end print record.to_binary_s end