Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/ruby
- require 'time'
- require 'date'
- def logintime(data)
- if data.match(/Accepted publickey for/)
- line_to_breakdown = data
- login_time = line_to_breakdown.match(/[A-Z][a-z][a-z]\s\s\d\s\d\d:\d\d:\d\d/)
- ip_address = line_to_breakdown.match(/(\d{1,3}\.){3}\d{1,3}/)
- venue = line_to_breakdown.match(/[a-z]\d\d\d\d/)
- puts "#{ip_address}" "\t" "#{login_time}" "\t" "#{venue}"
- end
- end
- counter = 1
- file = File.new("logexample", "r")
- while (line = file.gets)
- logintime(line)
- counter = counter + 1
- end
- file.close
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement