Advertisement
Guest User

Untitled

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