Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi All,
I'm monitoring log files of testcases. The logfile always contains a last line where the status is reported (successful/NOT successful). I'm able to find these status reports with following commandline script:
For /F "tokens=*" %%A in ('Dir /B /A:-D %1') Do (
type %%~fA | find "INFO - Testcase was successful!" >> D:\scripts\splitfiles\logs\temp\successful.txt
For /F "tokens=*" %%A in ('Dir /B /A:-D %1') Do (
type %%~fA | find "INFO - Testcase was NOT successful!" >> D:\scripts\splitfiles\logs\temp\not_successful.txtBut now my question:
How can I find the last 2 ERROR lines in my logfile?
Here is an example of my last logfile:
04 Aug 2008, 11:24:06 ERROR - Assertion failed param1: 1 matching "MercuryTest_21588" param2: No matches assertionType: CONTAINS
04 Aug 2008, 11:24:06 INFO - Condition was false
04 Aug 2008, 11:24:29 INFO - ***** Executing Step: Step 3 *****
04 Aug 2008, 11:24:31 INFO - Loaded URL: http://test.wap.xxxxxx.com/xxxxxxxx... successfully
04 Aug 2008, 11:24:31 ERROR - Failed at Step 3: field 1 - 2 (MercuryTest_21588) not found(Control type: [link] Criteria: [.text] Criteria value: [1 - 2 (MercuryTest_21588)])
04 Aug 2008, 11:24:31 ERROR - Failed at Step 3: field not found(Control type: [link] Criteria: [.text] Criteria value: [1 - 2 (MercuryTest_21588)])
04 Aug 2008, 11:24:31 INFO - ***** Executing Step: Reset Promos *****
04 Aug 2008, 11:24:31 INFO - start call of sequence: WAP:xxxxCommons.ResetAllPromotionAreas
04 Aug 2008, 11:24:31 INFO - start call of sequence: WAP:xxxxCommons.SchedulePromotion
04 Aug 2008, 11:24:33 INFO - Loaded URL: http://test.xxxxxxxx.xxxx.com/defau... successfully
04 Aug 2008, 11:25:04 INFO - Useragent set to IE6
04 Aug 2008, 11:25:04 INFO - Loaded standard security configuration
04 Aug 2008, 11:25:04 INFO - Testcase was NOT successful!I'm only interested in the last two ERROR lines, I want to pipe the contents of these to the "not_successfull.txt" but I cannot find how to achieve that?
Any help will be greatly appreciated!
Thanks in advance!
Igor

Igor, just a guess, dunno for sure. Seems to me you could just define a variable to be the last two and update it at each test. Normally ignored, the variable could then be echoed or printed out if the test fails?
HTH.
Ed in Texas.

![]() |
caps and spaces appear at...
|
Show Folder Name.
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |