Thanks, is there any other way without using external command?<br><br><div class="gmail_quote">On Fri, May 13, 2011 at 10:41 PM, Ishwor Gurung <span dir="ltr"><<a href="mailto:ishwor.gurung@gmail.com">ishwor.gurung@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi.<br>
<br>
On 14 May 2011 14:46, Far.Runner <<a href="mailto:far.runner@gmail.com">far.runner@gmail.com</a>> wrote:<br>
> Hi Python Experts:<br>
> There are two network interfaces on my laptop, one is<br>
> 100M Ethernet interface, the other is wifi interface, both are connected and<br>
> has an IP address. then the question is: how to get the ip address of the<br>
> wifi interface in a python script?<br>
> OS: Windows or Linux<br>
<br>
Detect the OS with <a href="http://os.name" target="_blank">os.name</a> and branch out to specific use case.<br>
<br>
The specific functionality can be implemented 2 ways:<br>
1/ Regular expression pattern match<br>
2/ Substring match and splits<br>
<br>
The subprocess module will then let you run those commands.<br>
1/ posix - (Linux in your case) will use ifconfig<br>
2/ nt - (windows in your ase) will use ipconfig.<br>
<br>
HTH.<br>
<br>
<br>
<br>
--<br>
<br>
Regards<br>
Ishwor Gurung<br>
Key id:0xa98db35e<br>
Key fingerprint:FBEF 0D69 6DE1 C72B A5A8 35FE 5A9B F3BB 4E5E 17B5<br>
<font color="#888888">--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</font></blockquote></div><br>