ifconfig in python

James Mills prologic at shortcircuit.net.au
Mon Jan 19 19:34:04 EST 2009


On Tue, Jan 20, 2009 at 10:28 AM, Nehemiah Dacres <vivacarlie at gmail.com> wrote:
> Is ther an easy way to get the resolved ip address of the machine a script
> is running on? socket.gethostbyname(socket.gethostname) has only returned
> the ip address of my loop back interface ... not very usefull.

That's because your /etc/hosts resolves
your hostname to 127.0.0.1 :)

And no I know of no "easy" way cross
platform way. Perhaps parsing the output
of ifconfig itself ?

cheers
James



More information about the Python-list mailing list