Determine ip address
Andy Jeffries
news at andyjeffries.co.uk
Fri Apr 15 11:35:55 EDT 2005
codecraig wrote:
> hi,
> how can i use python to figure the ip address of the machine which
> the python script is running on? I dont mean like 127.0.0.1....but i
> want the external IP address (such as ipconfig on windows displays).
I use the following (all on one line):
external_ip = os.popen("/sbin/ifconfig eth0|/bin/grep inet|/bin/awk
'{print $2}' | sed -e s/.*://", "r").read().strip()
Cheers,
Andy
More information about the Python-list
mailing list