vendredi 26 mai 2017

Batch file, string variable comparison, if statement

I am trying to compare the logs of a file with a plain string, but it is not getting into if comparison. I am getting " Connect failed" as my 2nd token in echo statement, but not getting any result of IF statement.

@echo off
rem start cmd.exe
for /f "tokens=2 delims=:" %%n IN (C:\Users\rohit.bagjani\Desktop\result\telnetresult.txt) DO (
    SET str1 = " Connect failed"
    echo %%n
    if \i %str1%==%%n echo "true"
)
echo.
pause

Aucun commentaire:

Enregistrer un commentaire