Permalink
Browse files

intial import

  • Loading branch information...
drapergeek committed Aug 31, 2011
0 parents commit a13cfa19042a936c8ee4feec79fec3eff928c6dc
Showing with 38 additions and 0 deletions.
  1. +1 −0 ips.txt
  2. +37 −0 ping_test.rb
@@ -0,0 +1 @@
+192.168.0.1
@@ -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.