I am trying to modify .bat script and have a problem with compare of two values.
Firstly I tried to do like this:
Code: Select all
for /f "usebackq tokens=1,2 delims=:" %%a in (`nslookup %2`) do (
echo %%a:%%b ^</br^> >> %opt%
echo %%b | FINDSTR /I /C:"%3"
if errorlevel 1 (
echo ^<td class="tg-031f"^>NOT %3^</td^> >> %opt%
) else (
echo ^<td class="tg-031s"^>OK %3^</td^> >> %opt%
)
)
%3 is read from file
So its looking if value %3 from the file is found inside string %%b (output is a string in 5 lines - the result is always in 4th line if it can help). If it is errorlevel 1 (values are not the same) the result is NOT, and if values are the same the result is OK.
It's working how I want but all this is saving to .html file and the tables doesn't create good because "if" is inside "for" loop and its looking %3 in each line separately (so in total there is 5 results).
The idea is to take "if" outside of for loop:
Code: Select all
set output=0
for /f "usebackq tokens=1,2 delims=:" %%a in (`nslookup %2`) do (
echo %%a:%%b ^</br^> >> %opt%
echo %%b >> %output%
)
echo %output% | FINDSTR /I /C:"%3"
if errorlevel 1 (
echo ^<td class="tg-031f"^>NOT %3^</td^> >> %opt%
) else (
echo ^<td class="tg-031s"^>OK %3^</td^> >> %opt%
)
But here the problem is that errorlevel doesn't work. I would like to achive that script will try to find each %3 parameter for each run of for loop.
I hope it is clear what I wrote here