Prev: RESOLVED Re: dll errors in compiled python program
Next: Accessing an instance of a class from within instance of anotherclass
From: Hans Mulder on 30 Apr 2010 06:01 joamag wrote: > It's not my ip address that I want to discover... I want to discover > my default dns server ip address. > This ip is stored in an operative system basis. > > Dos anyone know how to get it ? You asked for a cross-platform solution; there probably isn't one. The code below works on Unix and MacOS X. If you can find code that works on Windows, you can cobble together somthing that will work on most platforms. dns_ips = [] for line in file('/etc/resolv.conf', 'r'): columns = line.split() if columns[0] == 'nameserver': dns_ips.extend(columns[1:]) print dns_ips Hope this help, -- HansM |