Path: csiph.com!x330-a1.tempe.blueboxinc.net!aioe.org!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python': 0.07; 'from:addr:timgolden.me.uk': 0.09; 'from:name:tim golden': 0.09; 'message-id:@timgolden.me.uk': 0.09; 'parsing': 0.09; 'wifi': 0.09; 'pm,': 0.11; 'linux': 0.11; 'interfaces': 0.12; 'output': 0.12; 'wrote:': 0.14; 'os:': 0.16; 'received:74.55.86': 0.16; 'received:74.55.86.74': 0.16; 'received:smtp.webfaction.com': 0.16; 'received:webfaction.com': 0.16; 'subject:interface': 0.16; 'windows:': 0.16; 'wmi': 0.16; 'subject:address': 0.16; 'shell': 0.19; 'command': 0.19; 'cc:no real name:2**0': 0.20; 'cc:2**0': 0.20; 'interface': 0.20; 'header:In-Reply-To:1': 0.22; 'cc:addr :python-list': 0.22; 'skip:( 30': 0.24; 'script': 0.26; 'windows': 0.26; 'cc:addr:python.org': 0.31; 'tjg': 0.31; 'import': 0.32; 'received:192.168.1': 0.34; 'received:192': 0.34; 'there': 0.35; 'print': 0.35; 'question': 0.35; 'header:User-Agent:1': 0.35; 'received:192.168': 0.37; 'two': 0.37; 'some': 0.37; 'connected': 0.37; 'useful': 0.37; 'how': 0.39; 'from:addr:mail': 0.60; 'address': 0.61; 'subject:Get': 0.74; 'to:none': 0.92 Date: Sun, 15 May 2011 12:12:07 +0100 From: Tim Golden User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101129 Lightning/1.0b2 Thunderbird/3.1.7 MIME-Version: 1.0 CC: python-list@python.org Subject: Re: Get the IP address of WIFI interface References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 28 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1305457939 news.xs4all.nl 81479 [::ffff:82.94.164.166]:38843 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:5421 On 15/05/2011 12:04 PM, Neal Becker wrote: > Far.Runner wrote: > >> Hi python experts: >> There are two network interfaces on my laptop: one is 100M Ethernet >> interface, the other is wifi interface, both are connected and has an ip >> address. >> The question is: How to get the ip address of the wifi interface in a python >> script without parsing the output of a shell command like "ipconfig" or >> "ifconfig"? >> >> OS: Windows or Linux >> >> F.R > > Here's some useful snippits for linux: ... and for Windows: import wmi for nic in wmi.WMI ().Win32_NetworkAdapterConfiguration (IPEnabled=1): print nic.Caption, nic.IPAddress TJG