Solved

Get IP Address (Batch File)

Posted on 2004-09-06
7
5,955 Views
Last Modified: 2012-06-27
I want to get the external Ip address of a computer. The computer has two IP addresses, one on the PPP adapter and one on the local network connection.

I want the one that can be seen from the internet.

It'll be passed into a batch file so i would consider a great answer to be if someone could parse the ipconfig details:


Windows 2000 IP Configuration

Ethernet adapter Local Area Connection:

      Connection-specific DNS Suffix  . :
      IP Address. . . . . . . . . . . . : 192.168.0.1
      Subnet Mask . . . . . . . . . . . : 255.255.255.0
      Default Gateway . . . . . . . . . :

PPP adapter BT Yahoo! Broadband:

      Connection-specific DNS Suffix  . :
      IP Address. . . . . . . . . . . . : 81.154.249.XX
      Subnet Mask . . . . . . . . . . . : 255.255.255.255
      Default Gateway . . . . . . . . . : 81.154.249.XX

(I've convered the last two octets for security reasons but they would be there!)

Can anyone help me parse this file or get me the IP address another way?

Thanks

 Phillip Taylor
0
Comment
Question by:Philluminati
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 57

Accepted Solution

by:
Pete Long earned 250 total points
ID: 11992032
Hi Philluminati,
see http:Q_20743821.html#9399250

Cheers!
0
 

Author Comment

by:Philluminati
ID: 11992079
Nope....doesn't work.

Doesn't even seem like a similar question if you ask me. Can someone parse the IP Address in the bottom half of the print out (above) and give me the code to do it?

Thanks

  Phill
0
 

Expert Comment

by:darkpred-learning
ID: 12086600
why dont u try this....

ipconfig/all > C:/path/ip.log

and then add a string with the value "mailto:" and your email...
0
On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

 
LVL 1

Expert Comment

by:shanekelly_7
ID: 12239282
Okay! I have made in the past a batch file that does exactly that!

------Start of Batch Script!-----
@echo off
:: edit the two lines Below for your subject line and your email address
set to=someone@domain.com
set sub=Subject_line

for /f "tokens=2* delims=:" %%a in ('ipconfig ^| find "IP Address"') do set ip=%%a
set sub=%sub: =+%
start mailto:%to%?subject=%sub%^&body=The+IP+is;+%ip%
exit
-----End of Batch Script!-----

Good Luck!
- Shane
0
 
LVL 1

Expert Comment

by:shanekelly_7
ID: 12239353
Sorry Mate my Code need a little Debuging.
Use this:
------Start of Batch Script!-----
@echo off
:: edit the two lines Below for your subject line and your email address
set to=someone@domain.com
set sub=Subject_line

for /f "tokens=2* delims=:" %%a in ('ipconfig ^| find "IP Address"') do set ip=%%a
set sub=%sub: =+%
set ip=%ip: =+%
start mailto:%to%?subject=%sub%^&body=The+IP+is;+%ip%
exit
-----End of Batch Script!-----

Good Luck! (again)
- Shane
0
 

Author Comment

by:Philluminati
ID: 12240448
This posting ended ages ago. I've solved the problem and awarded the points to the name specified.
0
 
LVL 1

Expert Comment

by:shanekelly_7
ID: 12241516
Just adding extra help
0

Featured Post

Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
One of my most closely kept secrets is revealed in this discussion How to output text on the same line This question was recently posted in EE by Simon336697 (http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_2459…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question