import sys, socketdef getipaddrs(hostname): result = socket.getaddrinfo(hostname, None, 0, socket.SOCK_STREAM) return [x[4][0] for x in result]hostname = socket.gethostname()print "Host name:", hostnameprint socket.getfqdn(hostname)try: print ", ".join(getipaddrs(hostname))except socket.gaierror, e: print "Couldn't not get IP addresses:", e
Name (required)
email (will not be published) (required)
Website