| delorie.com/archives/browse.cgi | search |
| Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
| List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
| List-Archive: | <http://sources.redhat.com/ml/cygwin/> |
| List-Post: | <mailto:cygwin AT cygwin DOT com> |
| List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs> |
| Sender: | cygwin-owner AT cygwin DOT com |
| Mail-Followup-To: | cygwin AT cygwin DOT com |
| Delivered-To: | mailing list cygwin AT cygwin DOT com |
| To: | cygwin AT cygwin DOT com |
| From: | Chris Herborth <chrish AT cryptocard DOT com> |
| Subject: | Re: hot to get IP from shell -> C solution |
| Date: | Thu, 22 Apr 2004 12:58:51 -0400 |
| Organization: | CRYPTOCard (www.cryptocard.com) |
| Lines: | 25 |
| Message-ID: | <c68tjs$amh$1@sea.gmane.org> |
| References: | <c68mf0$l50$1 AT sea DOT gmane DOT org> |
| Reply-To: | chrish AT cryptocard DOT com |
| Mime-Version: | 1.0 |
| X-Complaints-To: | usenet AT sea DOT gmane DOT org |
| X-Gmane-NNTP-Posting-Host: | 207.35.237.35 |
| User-Agent: | Mozilla Thunderbird 0.5 (Windows/20040207) |
| In-Reply-To: | <c68mf0$l50$1@sea.gmane.org> |
electa wrote:
> /* little utility to get the IP address of the machine
> - prints the IP address in triple-dotted form xxx.yyy.zzz.www,
> or nothing if can't get it.
> - this code is a fragment from EpidEm code.
> */
The Python one is easier... ;-)
#!/usr/bin/env python
# Print IP address of the machine, or nothing.
import socket
try:
print socket.gethostbyname( socket.gethostname() )
except:
pass
Perl's probably just as easy.
--
Chris Herborth chrish AT cryptocard DOT com
Documentation Overlord, CRYPTOCard Corp. http://www.cryptocard.com/
Never send a monster to do the work of an evil scientist.
Postatem obscuri lateris nescitis.
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |