Created
August 4, 2014 19:23
-
-
Save btm/7be7c484b8d8ce737441 to your computer and use it in GitHub Desktop.
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
# Test DNS on Windows | |
wmi = WmiLite::Wmi.new | |
host = wmi.first_of('Win32_ComputerSystem') | |
hostname = "#{host['name']}" | |
machinename = "#{host['name']}" | |
x = 0 | |
while x < 10 | |
info = Socket.gethostbyname(Socket.gethostname) | |
if info.first =~ /.+?\.(.*)/ | |
puts "fqdn found via gethostbyname: #{info.first}" | |
else | |
#host is not in dns. optionally use: | |
#C:\WINDOWS\system32\drivers\etc\hosts | |
fqdn = Socket.gethostbyaddr(info.last).first | |
puts "fqdn found via gethostbyaddr: #{fqdn}" | |
end | |
x = x + 1 | |
sleep 5 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment