Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'python': 0.07; 'case)': 0.09; 'received:mail-bw0-f46.google.com': 0.09; 'subprocess': 0.09; 'substring': 0.09; 'wifi': 0.09; 'linux': 0.11; 'interfaces': 0.12; 'wrote:': 0.14; '(windows': 0.16; 'os.name': 0.16; 'os:': 0.16; 'posix': 0.16; 'received:209.85.214.46': 0.16; 'splits': 0.16; 'subject:interface': 0.16; 'ways:': 0.16; 'case.': 0.16; 'subject:address': 0.16; 'interface': 0.20; 'header:In- Reply-To:1': 0.22; 'detect': 0.25; 'windows': 0.26; 'message- id:@mail.gmail.com': 0.28; 'pattern': 0.31; 'match': 0.31; 'to:addr:python-list': 0.32; 'expression': 0.33; 'implemented': 0.33; 'module': 0.33; 'regular': 0.34; 'there': 0.35; 'question': 0.35; 'two': 0.37; 'connected': 0.37; 'received:209.85': 0.37; 'run': 0.37; 'received:google.com': 0.38; 'received:209.85.214': 0.39; 'to:addr:python.org': 0.39; 'received:209': 0.39; 'how': 0.39; '8bit%:8': 0.39; 'header:Received:5': 0.40; 'address': 0.61; '2011': 0.62; 'skip:1 20': 0.73; 'subject:Get': 0.74; '(linux': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type:content-transfer-encoding; bh=5l6hKCA/J3Z8dm0u9GMjRzjvp6/vEH0WEwCd+Itf4EI=; b=byTjhdxWRfnday1uqAFtmauUPN3VrWjT4Z7jZ5GO8Szd1mRfCaOHJUkBukHoLtb4Y8 svae/wRdTISMx+rFN4IaYeH/OwXbgkJMJ+nKpdETVONk2N4yPs8G7MJJer6fqPUFtOp5 fy/kIctgMI9xwVFnxoG2id6WdIRZtPluD/UAg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=d+vcbDGsOwQs1zsyKESVuhN4qUTL5u7J0lYDglp/R+NnhuvPLT2T30BmcXzT6pTzC3 1hR6E4rKycK13BdIluP/Xs3ME4j8s3ulPIF+8mxgGp4myImRxZCHss//8YRcNr1TJsSR JG8KXN8xxIaKvplo1JyD0XFTZ/288KACKFltc= MIME-Version: 1.0 In-Reply-To: References: Date: Sat, 14 May 2011 15:41:05 +1000 Subject: Re: Get IP address of WIFI interface From: Ishwor Gurung To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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: 31 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1305351668 news.xs4all.nl 81481 [::ffff:82.94.164.166]:59562 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:5336 Hi. On 14 May 2011 14:46, Far.Runner wrote: > Hi Python Experts: > There are two network interfaces on my laptop, one is > 100M=A0Ethernet=A0interface, the other is wifi interface, both are connec= ted and > has an IP address. then the question is: how to get the ip address of the > wifi interface in a python script? > OS: Windows or Linux Detect the OS with os.name and branch out to specific use case. The specific functionality can be implemented 2 ways: 1/ Regular expression pattern match 2/ Substring match and splits The subprocess module will then let you run those commands. 1/ posix - (Linux in your case) will use ifconfig 2/ nt - (windows in your ase) will use ipconfig. HTH. --=20 Regards Ishwor Gurung Key id:0xa98db35e Key fingerprint:FBEF 0D69 6DE1 C72B A5A8=A0 35FE 5A9B F3BB 4E5E 17B5