
I have this script to get ip adress from cmd line that works fine

Code: Select all
@echo off
Title Getting The IP address
Setlocal EnableDelayedExpansion
set myServer=www.yahoo.com
for /f "tokens=1,2 delims=[]" %%a IN ('ping -n 1 !myServer!') DO (
if "%%b" NEQ "" set ip=%%b
)
echo The IP address of !myServer! is !ip!
EndLocal
Pause
My aim is how to write a function to get multiple ip ?
I give a try but without success

Code: Select all
@echo off
setlocal EnableDelayedExpansion
Title Getting The IP address
echo.
echo Getting The IP address......
set myServer=www.developpez.net www.yahoo.com bbat.forumeiro.com www.voila.fr www.orange.fr www.google.com
For %%a in (%myServer%) do call :test_ping %%a
Pause
:test_ping
echo.
echo.
for /f "tokens=1,2 delims=[]" %%a IN ('ping -n 1 %%a') DO (
if "%%b" NEQ "" set %2=%%b
)
echo The IP address of %1 is %2
So, i ask you here how to write it ? and what's my mistake ?
Thank you !