I’ve recently used a site that allows querying WHOIS servers and got annoyed by the requirement of every time typing in the captcha key, so I thought to myself: “Wouldn’t it be groovy to write a Groovy WHOIS client?”. Well, it is :) So without any further ado, I’m presenting that finished script to you.
def domain = args.length > 0
? args[0] : 'google.com'
def server = args.length > 1
? args[1] : 'whois.geektools.com'
new Socket(server, 43).withStreams {input, output ->
output << "${domain}\r\n"
println input.text
}
As you can see, the script uses Groovy extensions to JDK classes, such as Socket (method withStreams(Closure)), InputStream (getText()) and OutputStream(leftShift(Object)). Neat, huh?
Keep on coding!
Psyho
September 18th, 2008 at 3:27 pm #James
Hi, I found your blog on this new directory of WordPress Blogs at blackhatbootcamp.com/listofwordpressblogs. I dont know how your blog came up, must have been a typo, i duno. Anyways, I just clicked it and here I am. Your blog looks good. Have a nice day. James.
August 26th, 2010 at 5:27 pm #Jennny
:)