Machine identification

Tim Williams listserver at tdw.net
Wed Sep 8 14:17:26 EDT 2004


On Wed, 8 Sep 2004 12:59:57 -0500, Greg Lindstrom
<greg.lindstrom at novasyshealth.com> wrote:
> How can I get the name (or ip) of the machine where my python script is
> running?  I'd like to add it to my log entry.


import socket

print socket.gethostname()
print socket.getfqdn()

this_host = socket_gethostname()
print socket.gethostbyname(this_host)

# the following will give several IP addresses if you are
#multi-homed

print socket.gethostbyname_ex(this_host)




More information about the Python-list mailing list