fork download
  1. #!usr/bin/env ruby
  2.  
  3. filename = ARGV[0]
  4.  
  5. src_ip_hash = {}
  6. dst_ip_hash = {}
  7. src_port_hash = {}
  8. dst_port_hash = {}
  9.  
  10. File.foreach{filename} do |line|
  11. ary = src.split('.')
  12. p ary
  13. p ary[0..3]
  14. src_ip_hash = ary[0..3].join('.')
  15. p src_ip_hash
  16. p ary[4]
  17. src_port_hash = ary[4].to_i
  18. p src_port_hash
  19.  
  20. ary = dst.split('.')
  21. p ary
  22. p ary[0..3]
  23. dst_ip_hash = ary[0..3].join('.')
  24. p dst_ip
  25. p ary[4]
  26. p ary[4].chop
  27. dst_port_hash = ary[4].chop.to_i
  28. p dst_port_hash
  29. end
  30.  
  31. #送信元IPアドレス
  32.  
  33. ARGV.each do |num|
  34. num = num.to_i
  35. if src_ip_hash[num].nil?
  36. src_ip_hash[num] = 0
  37. end
  38. src_ip_hash[num] = src_ip_hash[num] + 1
  39. end
  40.  
  41. #p src_ip_hash
  42.  
  43. src_ip.keys.sort.each do |ip|
  44. puts "#{ip} is inputed #{src_ip_hash[ip]} times."
  45. end
  46. #宛先IPアドレス
  47. #dst_ip.keys.sort.each do |ip|
  48.  
  49. #end
  50.  
  51. #送信元ポート番号
  52. #src_port.keys.sort.each do |port|
  53.  
  54. #end
  55.  
  56. #宛先ポート番号
  57. #dst_port.keys.sort.each do |port|
  58.  
  59. #end
  60.  
  61.  
  62.  
Runtime error #stdin #stdout 0s 4760KB
stdin
Standard input is empty
stdout
Standard output is empty