Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Another whois question, is it possible for me to take the output of a telnet connection to a file.

telnet whois.internic.net 43

then I

=google.com

and get a response.

Can I get this to return to a file for processing after the connection closes.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Why not just use the whois command?

whois -h whois.internic.net =google.com > whois.txt

Though in this case I get a better answer from

whois =google.com > whois.txt

Addendum

Telnet is great for interactive exploration of arbitrary text-based TCP protocols (such as SMTP, WHOIS etc) but it isn't really good for scripting

try netcat instead

$ echo =google.com | nc whois.internic.net 43 > whois.txt

$ head whois.txt

Whois Server Version 2.0

Domain names in the .com and .net domains can now be registered
with many different competing registrars. Go to http://www.internic.net
for detailed information.

   Server Name: GOOGLE.COM.ZZZZZZZZZZZZZZZZZZZZZZZZZZZ.LOVE.AND.TOLERANCE.THE-WONDERBOLTS.COM
   IP Address: 50.62.130.9
   Registrar: GODADDY.COM, LLC



$ tail whois.txt
use electronic processes that are automated and high-volume to access or
query the Whois database except as reasonably necessary to register
domain names or modify existing registrations. VeriSign reserves the right
to restrict your access to the Whois database in its sole discretion to ensure
operational stability.  VeriSign may restrict or terminate your access to the
Whois database for failure to abide by these terms of use. VeriSign
reserves the right to modify these terms at any time.

The Registry database contains ONLY .COM, .NET, .EDU domains and
Registrars.



$ grep -i status whois.txt
   Status: clientDeleteProhibited
   Status: clientTransferProhibited
   Status: clientUpdateProhibited
   Status: serverDeleteProhibited
   Status: serverTransferProhibited
   Status: serverUpdateProhibited

I get same output from netcat as I do from script + telnet. netcat is a lot easier

$ grep 'Name Server' whois.telnet | dos2unix | tee a
   Name Server: NS1.GOOGLE.COM
   Name Server: NS2.GOOGLE.COM
   Name Server: NS3.GOOGLE.COM
   Name Server: NS4.GOOGLE.COM
$  grep 'Name Server' whois.netcat | tee b
   Name Server: NS1.GOOGLE.COM
   Name Server: NS2.GOOGLE.COM
   Name Server: NS3.GOOGLE.COM
   Name Server: NS4.GOOGLE.COM
$ diff -s a b
Files a and b are identical

Other ideas

The canonical tool for scripting telnet is expect.

The canonical tool for capturing terminal output is script.

In this case I think these would not suit your task (but you may disagree)

share|improve this answer
    
because it does not reply with the domain status –  Kurtis Bro Aug 6 '12 at 16:00
    
@Kurtis: see Addendum –  RedGrittyBrick Aug 6 '12 at 16:10
    
[~]$ echo =google.com | nc whois.internic.net 43 > whois.txt [~]$ cat whois.txt Whois Server Version 2.0 Domain names in the .com and .net domains can now be registered with many different competing registrars. Go to internic.net for detailed information. ~]$ doesnt seem to work –  Kurtis Bro Aug 6 '12 at 16:19
    
@Kurtis: what output were you expecting? nc and telnet return identical output for me. –  RedGrittyBrick Aug 6 '12 at 16:25
    
I used a different whois server. and got the result I was expecting :D –  Kurtis Bro Aug 6 '12 at 17:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.