whois.bac

'
' Simple implementation of the WHOIS protocol.
'
' Can lookup most used TLD's. November 2010, PvE - GPL.
' Some beautifications - June 2015.
'
'-------------------------------------------------------------------

SPLIT ARGUMENT$ BY " " TO arg$ SIZE dim

IF dim < 2 THEN
    PRINT NL$, "Usage: whois <domain>"
    PRINT
    PRINT "Examples:"
    PRINT TAB$(1), "whois linux.org"
    PRINT TAB$(1), "whois amazon.com"
    PRINT
    END
ENDIF

domain$ = arg$[1]

tld$ = MID$(domain$, INSTRREV(domain$, "."))

info$ = ""

SELECT tld$
    CASE ".org"
        serv$ = "whois.pir.org:43"
    CASE ".net";
    CASE ".edu";
    CASE ".com"
        serv$ = "whois.verisign-grs.net:43"
    CASE ".mobi"
        serv$ = "whois.dotmobiregistry.net:43"
    CASE ".pro"
        serv$ = "whois.registrypro.pro:43"
    CASE ".name"
        serv$ = "whois.nic.name:43"
    CASE ".biz"
        serv$ = "whois.pacificroot.com:43"
    CASE ".aero"
        serv$ = "whois.information.aero:43"
    CASE ".info"
        serv$ = "whois.afilias.info:43"
    CASE ".coop"
        serv$ = "whois.nic.coop:43"
    CASE ".us"
        serv$ = "whois.us:43"
    CASE ".ca"
        serv$ = "whois.cira.ca:43"
    CASE ".eu"
        serv$ = "whois.eu:43"
    CASE ".nl"
        serv$ = "whois.domain-registry.nl:43"
    CASE ".de"
        serv$ = "whois.denic.de:43"
    CASE ".uk"
        serv$ = "whois.nic.uk:43"
    CASE ".ws"
        serv$ = "whois.nic.ws:43"
    CASE ".in"
        serv$ = "whois.inregistry.net:43"
    CASE ".nu"
        serv$ = "whois.nic.nu:43"
    CASE ".tv"
        serv$ = "tvwhois.verisign-grs.com:43"
    DEFAULT
        PRINT "Sorry, cannot lookup domain '", domain$, "'!"
        END
END SELECT

OPEN serv$ FOR NETWORK AS connection

SEND domain$ & "\r\n" TO connection
REPEAT
    RECEIVE data$ FROM connection
    info$ = info$ & data$
UNTIL ISFALSE(WAIT(connection, 500)) OR LEN(data$) = 0

CLOSE NETWORK connection

PRINT info$

Generated by GNU Enscript 1.6.5.90.