Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Sergey http://haqu.net

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Domains Availability Checker

/*
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
*/

   1  
   2  #!/usr/bin/env ruby -w
   3  
   4  if ARGV.empty?
   5    puts <<-T
   6  domains availability checker by haqu
   7  usage: ./ava.rb url[.tld|.*] ...
   8    T
   9    exit
  10  end
  11  
  12  domains = []
  13  
  14  ARGV.each do |d|
  15    if d.include?(".*")
  16      dset = d.gsub(/\*/,"")
  17      domains << [ "#{dset}com", "#{dset}net", "#{dset}org" ]
  18    else
  19      domains << d
  20    end
  21  end
  22  domains.flatten!
  23  
  24  domains.each do |d|
  25    res, domain = "-", d
  26    unless domain.include?(".")
  27      domain += ".com"
  28    end
  29    whois = `whois #{domain}`
  30    res = "+" if whois.include?( "No match" )
  31    puts "#{res} #{domain}"
  32  end
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS