loops - Making a server ping pong tool in batch -
i've made there unexpected error in loop.
please help.
@echo off color 1f title (ash's script) server ping pong rem --------------------------------------------------------------------------------------------------------------- echo started %time% %date% > x:\scripts\serverping.txt rem --------------------------------------------------------------------------------------------------------------- /f "tokens=*" %%i in (x:\scripts\computerlists\serverlist.csv) ( ping %%i -n 1 -w 3 if errorlevel 0 ( echo %%i online %time%>> x:\scripts\serverping.txt ) else ( echo %%i offline %time%>> x:\scripts\serverping.txt ) ) rem ---------------------------------------------------------------------------------------------------------------
if errorlevel 0
true.
use instead:
if not errorlevel 1
also change redirection on echo files:
>>x:\scripts\serverping.txt echo %%i online %time%
this eliminates problem when last character number (of stream)
another issue %time%
evaluated when loop starts - dynamic time in log enable delayed expansion , use !time!
instead of %time%
Comments
Post a Comment