Guest User

Untitled

a guest
Feb 20th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. # ruby ping.rb |egrep 'FAIL|WORK' > log
  2.  
  3. require 'thread'
  4. results = []
  5. threads = []
  6. for u in File.read("top100").split
  7. domain = u.sub(%r[http.*?://],"")
  8. threads << Thread.new do
  9. d2=domain
  10. worked = system "ping -t 3 #{d2}"
  11. results << [worked ? 'WORKED' : 'FAILED', d2]
  12. end
  13. end
  14. threads.each{|t| t.join}
  15. puts results.sort.map{|x| x.join("\t")}.join("\n")
Add Comment
Please, Sign In to add comment