Re: [Tutor] [tutor] ipconfig

2006-08-10 Thread andrew clarke
On Thu, Aug 10, 2006 at 04:47:43PM +0300, [EMAIL PROTECTED] wrote:

> is there in python an independent from the system way to obtain the IP

>>> import socket
>>> hostname = socket.gethostname()
>>> ip = socket.gethostbyname(hostname)
>>> print ip
192.168.1.10
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] [tutor] ipconfig

2006-08-10 Thread Jason Massey
I found this on an artima forum:http://www.artima.com/forums/flat.jsp?forum=181&thread=113874
This worked on my machine (win xp):socket.getaddrinfo(socket.gethostname(), None)[0][4][0]On 8/10/06, [EMAIL PROTECTED]
 <[EMAIL PROTECTED]> wrote:hello list
is there in python an independent from the system way toobtain the IPi am playng aroundimport sysimport osipconfname={'nt':'ipconfig', 'posix':'ifconfig'}ipstr = os.popen
(ipconfname[os.name] ).read()#print ipstrbut i found out that answer depends on os.name ...in this case i have to use a different parser for each
system ... so is there another way to retrieve the IP?regards,e.-http://www.atol.bg - Намери бившите си съученици и стари приятели!
___Tutor maillist  -  Tutor@python.orghttp://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] [tutor] ipconfig

2006-08-10 Thread emilia12
hello list

is there in python an independent from the system way to
obtain the IP

i am playng around

import sys
import os
ipconfname={'nt':'ipconfig', 'posix':'ifconfig'}
ipstr = os.popen(ipconfname[os.name] ).read()
#print ipstr

but i found out that answer depends on os.name ...

in this case i have to use a different parser for each
system ... so is there another way to retrieve the IP?

regards,
e.

-

http://www.atol.bg - Намери бившите си съученици и стари приятели!

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor