Viewing An IP Address in Command Prompt

Reply

Join Date: Aug 2004
Posts: 350
Reputation: Ghost is an unknown quantity at this point 
Solved Threads: 2
Ghost's Avatar
Ghost Ghost is offline Offline
Posting Whiz

Viewing An IP Address in Command Prompt

 
0
  #1
May 25th, 2005
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.
Reply With Quote Quick reply to this message  
Join Date: Mar 2004
Posts: 3,826
Reputation: Catweazle is a jewel in the rough Catweazle is a jewel in the rough Catweazle is a jewel in the rough Catweazle is a jewel in the rough 
Solved Threads: 144
Team Colleague
Catweazle Catweazle is offline Offline
Grandad
Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

Re: Viewing An IP Address in Command Prompt

 
0
  #3
May 25th, 2005
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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 350
Reputation: Ghost is an unknown quantity at this point 
Solved Threads: 2
Ghost's Avatar
Ghost Ghost is offline Offline
Posting Whiz

Re: Viewing An IP Address in Command Prompt

 
0
  #4
May 25th, 2005
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.
Reply With Quote Quick reply to this message  
Join Date: Dec 2003
Posts: 6,439
Reputation: DMR will become famous soon enough DMR will become famous soon enough 
Solved Threads: 362
Team Colleague
DMR's Avatar
DMR DMR is offline Offline
Wombat At Large

Re: Viewing An IP Address in Command Prompt

 
0
  #5
May 25th, 2005
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.
"May the Wombat of Happiness snuffle through your underbrush."
- Ancient Aborigine blessing


Please do not contact me by email or PM for help. We're all volunteers here, and only have so much free time to dedicate to our efforts.

However, if I've been working on a thread with you already, and seem to have "forgotten" your thread, please do send me a message. I try not to let things slip through the cracks, but it does happen sometimes.
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 350
Reputation: Ghost is an unknown quantity at this point 
Solved Threads: 2
Ghost's Avatar
Ghost Ghost is offline Offline
Posting Whiz

Re: Viewing An IP Address in Command Prompt

 
0
  #6
May 25th, 2005
thanx. one more question. is there a way to return the ip address to a java/c++ program?
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

Re: Viewing An IP Address in Command Prompt

 
0
  #7
May 25th, 2005
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.
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

Re: Viewing An IP Address in Command Prompt

 
0
  #8
May 25th, 2005
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());
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Windows NT / 2000 / XP Forum


Views: 11191 | Replies: 7
Thread Tools Search this Thread



Tag cloud for Windows NT / 2000 / XP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC