commandlinefu.com is the place to record those command-line gems that you return to again and again.
You can sign-in using OpenID credentials, or register a traditional username and password.
Subscribe to the feed for:
The socket.gethostname() call returns the host name of the computer. The socket.gethostbyname_ex() call returns a list of three items: The host name, the list of aliases for this host, and a list of IP addresses. Recall that Python?s array starts with index 0, the socket.gethostbyname_ex(?) expression refers to the list of IP addresses. Finally, the print statement prints out the IP addresses, one per line.
There are 7 alternatives - vote for the best!
If you can do better, submit your command here.
You must be signed in to comment.