#!/usr/bin/python

# print_host_names.py
#       --copyright--                   Copyright 2007 (C) Tranzoa, Co. All rights reserved.    Warranty: You're free and on your own here. This code is not necessarily up-to-date or of public quality.
#       --url--                         http://www.tranzoa.net/tzpython/
#       --email--                       pycode is the name to send to. tranzoa.com is the place to send to.
#       --bodstamps--
#       July 16, 2007           bar
#       November 18, 2007       bar     turn on doxygen
#       November 21, 2007       bar     import-able
#       November 27, 2007       bar     insert boilerplate copyright
#       May 17, 2008            bar     email adr
#       --eodstamps--
##      \file
#
#


import re
import sys
import socket

if __name__ == '__main__' :
    a   = []

    if  len(sys.argv) > 1 :
        sys.argv.pop(0)

        while len(sys.argv) :
            li  = sys.argv.pop(0)

            a.append(li)
        pass
    else :
        while True :
            li  = sys.stdin.readline()
            if  not li :
                break

            a.append(li.strip())
        pass

    for li in a :

        g   = re.search(r"(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})", li)
        if  g :
            adr     = g.group(1)
            try :
                h   = socket.gethostbyaddr(adr)
                print h
            except socket.herror :
                print "('', [], [" + adr + "]) not found"
        pass

    pass


#
#
# eof

