Skip to content

Commit

Permalink
intial import
Browse files Browse the repository at this point in the history
  • Loading branch information
drapergeek committed Aug 31, 2011
0 parents commit a13cfa1
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions ips.txt
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1 @@
192.168.0.1
37 changes: 37 additions & 0 deletions ping_test.rb
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/ruby
require "rubygems"
require 'net/ping'

tcp = Net::Ping::ICMP.new
#Read in the ips
IP_LIST = "ips.txt"
ips = Array.new
File.open(IP_LIST, "r") do |infile|
while (line = infile.gets)
unless line.index('#') == 0
puts "Adding ip #{line}"
ips << line.chomp
end
end
end


ips.each do |ip|
if tcp.ping?(ip)
ips.delete(ip)
puts "Remove #{ip} from list because it was found"
end
end



File.open(IP_LIST, 'w') do |outfile|
ips.each do |ip|
puts ip
outfile.puts ip
end
end




0 comments on commit a13cfa1

Please sign in to comment.