[Tutor] Finding all IP addresses associated with a host

Scott Newton scott.newton at gmail.com
Thu Apr 9 23:52:17 CEST 2009


I'm very new to python, and my google-fu has failed to locate an answer to
the following:

How can I find all of the (ipv4) addresses that are currently up on a host?

I realize I can call ifconfig and then munge the output with awk, but that
seems messy, and before I tried that I though I would ask around.

To give a bit more information, I'm writing a script that will use the ip
address assigned to the wifi interface to determine location (this is on a
Mac) and then mount network drives appropriate to the location. If anyone
has a better idea how to do this, I'd be happy to hear them.

Thanks in advance!

Scott Newton
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090409/4a770f11/attachment.htm>


More information about the Tutor mailing list