grab ip

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
DiomZ
Posts: 2
Joined: 27 Sep 2016 03:42

grab ip

#1 Post by DiomZ » 27 Sep 2016 03:50

please help me... how to grab ip chicken result using batch files and have an out file logs

ShadowThief
Expert
Posts: 1167
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: grab ip

#2 Post by ShadowThief » 27 Sep 2016 07:58

Batch doesn't play nice with things that have GUIs, and especially not with websites.

Your best bet is to download the webpage with cURL or wget and then parse it with findstr.

aGerman
Expert
Posts: 4724
Joined: 22 Jan 2010 18:01
Location: Germany

Re: grab ip

#3 Post by aGerman » 27 Sep 2016 11:04

Forget about IP Chicken. There are web services that are made for this kind of automation. E.g. http://myip.dnsomatic.com/. The site consists of the plain IP address only (without any HTML, CSS, JavaScript, ...).
You can easily read it using WSH. And if you want you could write a hybrid script in order to save it in a batch variable.

getIP.bat

Code: Select all

@if (@a)==(@b) @end /* ~~~ Batch part: ~~~

@echo off &setlocal
for /f "delims=" %%i in ('cscript //nologo //e:jscript "%~fs0"') do set "ip_addr=%%i"
echo IP Address: %ip_addr%
pause
exit /b

~~~ JScript part: ~~~ */
try {
  var objXMLHTTP = new ActiveXObject('Microsoft.XMLHTTP');
  objXMLHTTP.Open('GET', 'http://myip.dnsomatic.com/', false);
  objXMLHTTP.Send();
  if (objXMLHTTP.readyState == 4 && objXMLHTTP.status == 200) {
    WScript.Echo(objXMLHTTP.responseText);
  } else {
    WScript.Echo('Error');
  }
}
catch(e) {
  WScript.Echo('Error');
}

Steffen

DiomZ
Posts: 2
Joined: 27 Sep 2016 03:42

Re: grab ip

#4 Post by DiomZ » 27 Sep 2016 20:43

thanks for your time master aGerman &
Master ShadowThief..
Actually my plan was to get the UltraSurf dns proxy ip address has been created just to have a record logs file thru text files... so i was thinking just to grab the ip address creating by ipchicken or other websites... other solution for this issues masters...

thanks and more power... :idea: :idea: :idea:

aGerman
Expert
Posts: 4724
Joined: 22 Jan 2010 18:01
Location: Germany

Re: grab ip

#5 Post by aGerman » 28 Sep 2016 04:18

If the batch code displays the right IP address you can simply redirect it to a log file.
Instead of

Code: Select all

echo IP Address: %ip_addr%

you could write something like

Code: Select all

>>"IP.log" echo %date% %time% %ip_addr%

or whatever you want to log in the file.

Steffen

Post Reply