-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a13cfa1
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
192.168.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |||
|
|||
|
|||
|
|||
|