Find my www.whatismyip.com ip in DOS

Dell / Inspirion 1764
March 5, 2010 at 23:15:38
Specs: Windows 7 Home Premium, Athlon 64 3gb
Hi there. I am attempting to create a 1 or 2 line batch file that will simply output my IP address to a file. The only problem I'm having is that I can only get DOS to show me 192.168.1.3, but when I go to www.whatismyip.com I get 76.xxx.xxx.61.

If I could just get my batch file to output 76.xxx.xxx.61, I would be a happy camper. Any thoughts?

-Ronnie

PS: I looked and looked and for the life of me could not find anything on google for this.


See More: Find my www.whatismyip.com ip in DOS

Report •

#1
March 5, 2010 at 23:17:19
If I could just get my batch file to output 76.xxx.xxx.61
echo 76.xxx.xxx.61


Report •

#2
March 6, 2010 at 23:28:27
I don't think there's an easy way to do this in Windows (DOS doesn't have any native networking capabilities, so I assume you're using the command prompt). The best way I can think of is to download the NT console version of netcat.

http://joncraton.org/files/nc111nt.zip

You can fetch the contents of a web page with netcat by establishing a connection and then issuing the command "GET /". To script this you would just need to:

1. Create a file to send commands into netcat, such as "commands" with the content "GET /" (without quotes).
2. Run netcat with the command "nc www.whatismyip.org 80 < commands > outputfile

I'm not too good with string operations in batch files, but the IP address should be easy enough to pull out from the output file to someone more competent.


Report •

#3
March 7, 2010 at 07:09:34
Thanks idisjunction. I had a feeling I was going to need a 3rd party tool. I appreciate the help.

Report •
Related Solutions


Ask Question