DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Windows NT / 2000 / XP (http://www.daniweb.com/forums/forum10.html)
-   -   Viewing An IP Address in Command Prompt (http://www.daniweb.com/forums/thread24253.html)

Ghost May 25th, 2005 3:50 am
Viewing An IP Address in Command Prompt
 
Hi!

I was wondering if there's a way to view the IP address of a certain site through Command Prompt. Even better, maybe there's a way to access it through a c++ or java program!

thanx.

Catweazle May 25th, 2005 4:21 am
Re: Viewing An IP Address in Command Prompt
 
http://www.winability.com/hostname-c...ip-address.htm

server_crash May 25th, 2005 7:23 am
Re: Viewing An IP Address in Command Prompt
 
Quote:

Originally Posted by C++
Even better, maybe there's a way to access it through a c++ or java program!

thanx.

You can access a site through java without knowing the IP Address. look up the java.net.*; package.

Ghost May 25th, 2005 11:51 am
Re: Viewing An IP Address in Command Prompt
 
server_crash, thanx but i already know that. I wanted 2 make a program that tells u the ip address of the inputted domain name.

thanx anyway.

DMR May 25th, 2005 3:21 pm
Re: Viewing An IP Address in Command Prompt
 
Quote:

Originally Posted by C++
server_crash, thanx but i already know that. I wanted 2 make a program that tells u the ip address of the inputted domain name.

thanx anyway.

The ping command referenced in Catweazle's link will return the IP, although by default it will query a site 4 times, echo a response for every query, and then barf summary statistics on top of that. You can limit the query count with the "-n" switch, but it will still return the stats as well.

You might also check out the "nslookup" command.

Ghost May 25th, 2005 10:27 pm
Re: Viewing An IP Address in Command Prompt
 
thanx. one more question. is there a way to return the ip address to a java/c++ program?

server_crash May 25th, 2005 10:39 pm
Re: Viewing An IP Address in Command Prompt
 
Quote:

Originally Posted by C++
thanx. one more question. is there a way to return the ip address to a java/c++ program?

This is how you can grab the client ip address:
  InetAddress thisIp =
        InetAddress.getLocalHost();
    System.out.println("IP:"+thisIp.getHostAddress());

Remember to include that in a try catch clause, as that code could potentially cause an exception.

Also, writting a simple servlet would be easier:

String IP = req.getRemoteAddr();
req is an HTTPServletRequest Object.

server_crash May 25th, 2005 11:31 pm
Re: Viewing An IP Address in Command Prompt
 
Sorry, you might want to get it by the hostname:

java.net.InetAddress inetAdd =
java.net.InetAddress.getByName("www.ibm.com");
        System.out.println ("IP Address is : " + inetAdd.getHostAddress());


All times are GMT -4. The time now is 3:56 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC