Can anybody suggest what is wrong in following code.
@echo off
set /a x=1
:while
set /a sta=0
if %x% lss 5 (
for /f "tokens=4" %%i in ('ping 127.0.0.%x%') do (set sta="1"
if "%%i" == "bytes=32" (echo 111111111
set /a sta=1
)
)
if %sta% == 1 echo 127.0.0.%x% - ONLINE
if %sta% == 0 echo 127.0.0.%x% - OFFLINE
set /a x+=1
goto while
)
pause
It is always going to if condition 'if %sta% == 0'. It is never going to condition if %sta% == 1 .
It seems the sta variable value is not changing.