Compare Strings

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
osramos
Posts: 5
Joined: 27 Sep 2008 04:31

Compare Strings

#1 Post by osramos » 18 Jan 2009 18:26

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

jeb
Expert
Posts: 1055
Joined: 30 Aug 2007 08:05
Location: Germany, Bochum

#2 Post by jeb » 19 Jan 2009 13:33

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

osramos
Posts: 5
Joined: 27 Sep 2008 04:31

#3 Post by osramos » 20 Jan 2009 10:26

Hi jeb,

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

Thanks again

osramos

Post Reply