Advertisement
Guest User

Untitled

a guest
Dec 7th, 2011
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #!/usr/bin/ruby
  2. require 'time'
  3. require 'date'
  4.  
  5. def logintime(data)
  6. if data.match(/Accepted publickey for/)
  7. line_to_breakdown = data
  8. login_time = line_to_breakdown.match(/[A-Z][a-z][a-z]\s\s\d\s\d\d:\d\d:\d\d/)
  9.  
  10.  
  11. ip_address = line_to_breakdown.match(/(\d{1,3}\.){3}\d{1,3}/)
  12. venue = line_to_breakdown.match(/[a-z]\d\d\d\d/)
  13. puts "#{ip_address}" "\t" "#{login_time}" "\t" "#{venue}"
  14.  
  15. end
  16. end
  17.  
  18.  
  19. counter = 1
  20. file = File.new("logexample", "r")
  21. while (line = file.gets)
  22.  
  23. logintime(line)
  24.  
  25.  
  26. counter = counter + 1
  27. end
  28. file.close
  29.  
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement