2

I need to retrieve whois informations for a given site. because the whois content varies with each whois server, i need to parse the whois content what i'm getting.

I'm using php to show the content from db and initially tried in php to parse it. now i came to know there is ruby whois package which parses whois content.
so the idea is running ruby program in the background to put whois content in db then show using php if requests made.

I've installed ruby 1.8.7 and whois and tried examples given in ruby document. But its giving

/opt/lampp/htdocs/labs/ruby/ruby-whois.rb:1: uninitialized constant Whois (NameError)  

is rubywhois different from ruby? can anyone help me in this regard.

Simone Carletti
  • 173,507
  • 49
  • 363
  • 364
vkGunasekaran
  • 6,668
  • 7
  • 50
  • 59

2 Answers2

4

Have you installed the library with gem install whois? After that you have to require it in your code (require 'whois') in order to be able to use it.

Michael Kohl
  • 66,324
  • 14
  • 138
  • 158
  • No i just installed ruby using yum..Now i tried it but i got error message as "bash: gem: command not found..." – vkGunasekaran Sep 27 '11 at 10:36
  • 2
    Which version of Ruby did you install (check with `ruby -v`)? If it's 1.8.6 you might have to install Rubygems separately. See e.g. this tutorial for FC5: http://www.linuxweblog.com/ruby-on-rails-install. You don't need Rails btw, but the beginning of the tutorial should be interesting for you. – Michael Kohl Sep 27 '11 at 11:45
3

I've found. These are things i've done.

  • Installed ruby, using yum install ruby
  • tried gem install whois, it asked me whether to install gem package and installed.
  • After installing rubygem, i used gem install whois command

Now i created a file with .rb extension with the following content,

require 'rubygems'
require 'whois'
r = Whois.whois("google.com")
puts r.created_on  

I run this file in terminal with this command,

ruby /opt/lampp/htdocs/labs/ruby/ruby-whois.rb

and the output is,

Mon Sep 15 00:00:00 +0530 1997  

Thanks for all your efforts.

vkGunasekaran
  • 6,668
  • 7
  • 50
  • 59
  • 2
    Great you solved your problem. Please accept the answer above (the little tick mark under the vote count) so other see that this question has been answered. – Michael Kohl Sep 27 '11 at 12:21