Page 1 of 1

Compare Strings

Posted: 18 Jan 2009 18:26
by osramos
Hello. I need some help doing a bat file

The problem is this, i want to check if a log generated by TSM when finishes the backup everithyng is ok. The only thing i need to compare is this 2 lines

01/12/2009 09:24:53 Total SQL backups selected: 6
01/12/2009 09:24:53 Total SQL backups attempted: 6
01/12/2009 09:24:53 Total SQL backups completed: 6

01/12/2009 09:24:53 Total SQL backups excluded: 0
01/12/2009 09:24:53 Total SQL backups inactivated: 5

and the number on the end od the line ( in this case is 6 ). Is it's not equal then the bat file should return error. My problem is that i already use the FINDSTR to check both lines but i sees the line from start to the end, doesn't break before the number 6.

Is there a way to check these 2 lines and compare them ( should be only tne numbers because the lines are diferent from one another ).

Regards

osramos

Posted: 19 Jan 2009 13:33
by jeb
Hi osramos,

the findstr seems to be the right way.

But then you have to use the output and split it with the FOR /F "tokens=..." command.

Somthing like

Code: Select all

FOR /F "tokens=7" %%a in ('findstr "attempted" myFile.tmp') do set att=%%a
FOR /F "tokens=7" %%c in ('findstr "completed" myFile.tmp') do set comp=%%c


jeb

Posted: 20 Jan 2009 10:26
by osramos
Hi jeb,

thanks for prompt reply. I will test this and work a little more on the bat file.

Thanks again

osramos