On Sun, Jun 05, 2005, Lee Harr wrote:
>>At present, the only thing I can think of is to redirect the
>>output of 'ifconfig' into a temporary file, then read it back in and use
>>Python and regular expressions to try and extract the IP info from that.

Why go to a temporary file when you can open a pipe?

        import os
        fh = os.popen('ifconfig') #...

The advantage of parsing ifconfig output instead of using socket calls is
that it allows you to discriminate between multiple interfaces (e.g. most
of our dual hosted machines have the primary interface on the private
address which probably isn't what is required).

One disadvantage of parsing ifconfig is that output varies depending on the
operating system.

Bill
--
INTERNET:   [EMAIL PROTECTED]  Bill Campbell; Celestial Systems, Inc.
UUCP:               camco!bill  PO Box 820; 6641 E. Mercer Way
FAX:            (206) 232-9186  Mercer Island, WA 98040-0820; (206) 236-1676
URL: http://www.celestial.com/

``The fact is that the Constitution was intended to protect us from
the government, and we cannot expect the government to enforce it
willingly'' -- Dave E. Hoffmann, Reason Magazine March 2002
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to