Bach file to read txt and make an bat

May 29, 2010 at 20:01:34
Specs: Windows XP
I need to make a bat file that it will take a site ip address and it will make another bat with that ip and some other text

i did some try's
only that i did was to take ip from server but i cant copy it from the txt file since i dont know this code, i used this
nslookup mysitelala.org>C:\ip.txt
end

it gives this
Server: dsldevice.lan
Address: 192.168.1.254

Name: mysitelala.org
Address: 65.61.174.171

i just need to copy this line 65.61.174.171(the ip) from the txt everytime because it can change(static ip)..

and just to make a final bat with this info

Start myexe.exe 65.61.174.171(but the new ip always here)

End

i hope to get my point !
thanks in advance


See More: Bach file to read txt and make an bat

Report •

#1
May 29, 2010 at 20:20:33
@echo off & setlocal
for /f "skip=2 tokens=2" %%a in ('nslookup mysitelala.org ^|find "Address:"') do set ip=%%a
echo ip=%ip%
pause
start myexe %ip%
::----- end - not tested

Report •

#2
May 29, 2010 at 20:52:36
@echo off & setLocal enableDELAYedeXpansion

for /f "tokens=2 delims=[]" %%a in ('ping ibm.com -n 1 -w 1 ^| find "Pinging"') do (
echo Start myexe.exe %%a
)


=====================================
Helping others achieve escape felicity

M2


Report •

#3
May 30, 2010 at 09:34:23
I used this

setlocal
for /f "skip=1 tokens=2" %%a in ('nslookup mynet.org ^|find "Address:"') do set ip=%%a
echo ip=%ip%
start myexe.exe %ip%
::----- end

thank you both, scripts work well


Report •
Related Solutions


Ask Question