Skip to content

Instantly share code, notes, and snippets.

Created January 10, 2013 20:43
Show Gist options
  • Save anonymous/4505615 to your computer and use it in GitHub Desktop.
Save anonymous/4505615 to your computer and use it in GitHub Desktop.
@hostaddress = "192.168.2.5"
begin
@hostnamelookup = Resolv.getname(@hostaddress)
rescue Resolv::ResolvError
@hostnamelookup = ""
end
output:
/home/karl/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/resolv.rb:128:in `getname': no name for 192.168.2.5 (Resolv::ResolvError)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment