Created
August 15, 2013 01:58
-
-
Save hackworth/6237589 to your computer and use it in GitHub Desktop.
Watir script for getting hostnames from Cisco 1130 AG access points
This file contains hidden or 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
require 'watir-webdriver' | |
puts "Running Scan" | |
scan = %x(sudo nmap -PR -sn 10.208.0.0/22 | grep Cisco -B 2 | grep Nmap | sed 's/Nmap scan report for //') | |
puts "Running Webdriver" | |
noname = Array[] | |
browser = Watir::Browser.new | |
scan.lines.each do |host| | |
browser.goto "http://Cisco:Cisco@#{host}" | |
hostname = browser.text.lines.grep(/Hostname/)[0] | |
host = host.split(/\n/)[0] | |
if hostname | |
hostname = hostname.gsub(/Hostname\s+/, '') | |
puts "#{host} #{hostname}" | |
else | |
noname.push(host) | |
end | |
end | |
puts "Unknown Hostnames:" | |
noname.each { |h| puts h } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment