vendredi 25 septembre 2015

string comparison in batch file not working

I have this code:

SETLOCAL enabledelayedexpansion enableextensions


SET OutofService=Weblog_Doc(file:///C:/Bla/BlaKon.htm?send=2000)


        REM - Declare and set the Array
        FOR /f "delims=" %%a IN (C:\Folder1\log.dat) DO (
            SET /a c+=1
            SET x[!c!]=%%a          
        )   

        REM - Read Array from end to start
        FOR /l %%I IN (!c! -1 1) DO (                   

            SET _result=!x[%%I]:~-47%!      

            ECHO !_result!
            ECHO !OutofService!

            IF "!_result!"=="!OutofService!" (              
                ECHO yahooo!                
            )           
        )

The string in file is as follows: 09/17/15 15:18:52:577 Container: Weblog_Doc(file:///C:/Bla/BlaKon.htm?send=2000)

My ECHO statement is outputting the result:

Weblog_Doc(file:///C:/Bla/BlaKon.htm?send=2000)
Weblog_Doc(file:///C:/Bla/BlaKon.htm?send=2000)

the if statement is returning false and not outputting yahooo! as it should, given the fact that these two strings should be equal. What am I doing wrong?

Aucun commentaire:

Enregistrer un commentaire