This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: IP Lookup command


Try this quick hack.  It works for me under Cygwin 1.3.1:

#include <stdio.h>
#include <netdb.h>

int main(int argc, char * argv[])
{
    char ** addrlistelem;
    struct hostent * hostinfo;

    hostinfo = gethostbyname(argv[1]);

    if (hostinfo == NULL)
    {
	fputs("unknown host\n", stderr);
	exit(1);
    }

    addrlistelem = hostinfo->h_addr_list;
    while (*addrlistelem)
    {
	char * address = *addrlistelem;
	printf("%u.%u.%u.%u\n", address[0] & 0xff, address[1] & 0xff,
	       address[2] & 0xff, address[3] & 0xff);
	addrlistelem++;
    }

    exit(0);
}

-----Original Message-----
From: cygwin-owner@sources.redhat.com
[mailto:cygwin-owner@sources.redhat.com]On Behalf Of C. Porter Bassett
Sent: Thursday, May 31, 2001 1:20 PM
To: cygwin@cygwin.com
Subject: IP Lookup command


I need a command that I can call in the following manner:
$ unknown_command host_on_my_network
192.168.20.119
$

At least here on my network, neither nslookup nor host work, although
they
will go outside of my network and work just fine.  Ping manages to find
local computers in the way that I am looking for.  Should I just pass
ping
though some filter?


--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple



--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]