RSS Forums RSS

Viewing An IP Address in Command Prompt

Please support our Windows NT / 2000 / XP / 2003 advertiser: Programming Forums
Reply
Posts: 347
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

  #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.
AddThis Social Bookmark Button
Reply With Quote  
Posts: 3,732
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: 142
Colleague
Catweazle Catweazle is offline Offline
Grandad
Posts: 2,105
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

  #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  
Posts: 347
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

  #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  
Posts: 6,439
Reputation: DMR will become famous soon enough DMR will become famous soon enough 
Solved Threads: 340
Colleague
DMR's Avatar
DMR DMR is offline Offline
Wombat At Large

Re: Viewing An IP Address in Command Prompt

  #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  
Posts: 347
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

  #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  
Posts: 2,105
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

  #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  
Posts: 2,105
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

  #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  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Similar Threads
Other Threads in the Windows NT / 2000 / XP / 2003 Forum
Views: 10014 | Replies: 7 | Currently Viewing: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 1:46 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC