Monday, November 5, 2007

Ruby on Rails domain checking script

begin:vcard
fn:Cobus
n:;Cobus
note;quoted-printable:LEGAL NOTICE:=0D=0A=
=0D=0A=
PLEASE READ:The information contained in this e-mail is confidential and=
of a privileged nature. If you are not an intended recipient of this e-m=
ail you must not copy, use, distribute or take any further action in reli=
ance upon it and you should delete it and notify the sender. Any informat=
ion and content contained in this e-mail is subject to the legal notices,=
copyright and restrictions on use and disclaimer terms set out on Matoge=
n=E2=80=99s web site. E-mail is not a secure method of communication. Mat=
ogen and/or Managers cannot accept responsibility for the accuracy or com=
pleteness of this message or any attachment(s). This transmission could=
contain viruses, be corrupted, destroyed, be incomplete, intercepted,=
lost or arrive late. If verification of this e-mail is sought then pleas=
e request a hard copy. Unless otherwise stated any views or opinions pres=
ented are solely those of the author and do not represent those of Matoge=
n and/or Managers. This e-mail is intended for information purposes only=
and is not a solicitation or offer to buy or sell securities or related=
financial instruments.=0D=0A=
=0D=0A=
IF YOU DO NOT WISH TO RECEIVE FURTHER ELECTRONIC CORRESPONDENCE FROM MATO=
GEN, PLEASE INSTRUCT US TO REMOVE YOUR PERSONAL INFORMATION FROM OUR DATA=
BASE.=0D=0A=
=0D=0A=
Matogen and/or Managers will only respond to correspondence addressed to=
same in English.
version:2.1
end:vcard

/*
This script uses whois program to check domain for "No match" record.
Example of usage:
$ ./ava.rb ruby{,-}snippets rubyzone.*
- rubysnippets.com
+ ruby-snippets.com
- rubyzone.com
- rubyzone.net
- rubyzone.org
*/

#!/usr/bin/env ruby -w

if ARGV.empty?
puts <<-T
domains availability checker by haqu
usage: ./ava.rb url[.tld|.*] ...
T
exit
end

domains = []

ARGV.each do |d|
if d.include?(".*")
dset = d.gsub(/\*/,"")
domains << [ "#{dset}com", "#{dset}net", "#{dset}org" ]
else
domains << d
end
end
domains.flatten!

domains.each do |d|
res, domain = "-", d
unless domain.include?(".")
domain += ".com"
end
whois = `whois #{domain}`
res = "+" if whois.include?( "No match" )
puts "#{res} #{domain}"
end

--

No comments:

analytics