Show current ip on Linux

James Tanis jtanis at pycoder.org
Mon Jun 13 11:49:06 EDT 2005


Previously, on Jun 13, Qiangning Hong said: 

# David Van Mosselbeen wrote:
# > Hi,
# > Im a newbie in Python, and also in Fedora Core 3. (Yes, Linux is fine
# > man :-)
# > 
# > My question is : How can i rwite a script that show my current ip. If i have
# > more than one network card, the script must then show all used ip.
# > 
# > It's important that this will work on a linux. i Have rwite some piece of
# > code that realy work under Windows XP, but the same script wil not work on
# > Linux. 
# > 
# > Verry thanks to all vulunteers.
# > 
# 
# How about use the shell command "ifconfig | grep inet" ?
# 

I think you mean ifconfig -a|grep 'inet '

He needs to see all the interfaces, no options will only print a help 
message. 'inet ' will get get rid of the inet6 addresses assuming he 
doesn't need those.

# 
# -- 
# Qiangning Hong
# 
#  _____________________________________________________________
# ( <zhen> so <zhen> when I do a chroot /path /bin/bash, i can  )
# ( see the processes                                           )
# (                                                             )
# ( outside of the chroot <zhen> and i can kill those processes )
# ( * klieber claps for zhen <zhen> oh go die                   )
#  -------------------------------------------------------------
#        o   \_______
#  v__v   o  \   O   )
#  (OO)      ||----w |
#  (__)      ||     ||  \/\
# 
# -- 
# http://mail.python.org/mailman/listinfo/python-list
# 


---
James Tanis
jtanis at pycoder.org
http://pycoder.org



More information about the Python-list mailing list