ip address?

Emile van Sebille emile at fenx.com
Sat Jan 26 17:33:40 CET 2002


"maximilianscherr" <MaximilianScherr at T-Online.de> wrote in message
news:mailman.1012044521.3447.python-list at python.org...
> thanks, haven't tried it yet, but perhaps will work, and i only have
> two ips i think one for the lan and one for the net, so i just tell
> it if not "192.168.0.10" right?
>

Perhaps parsing route works better.  For win2k it takes the output from
route print, selects the rows where network destination is 0.0.0.0, and
selects the ip address of the interface that traffic routes through.

>>> import os
>>> ipaddr = [ i for i in os.popen('route print').readlines()
  if i.split()[0] == '0.0.0.0' ][0].split()[3]


HTH,

--

Emile van Sebille
emile at fenx.com

---------




More information about the Python-list mailing list