How to return multiple lines from text log

All questions related to installations, configurations and maintenance of Advanced Host Monitor (including additional tools such as RMA for Windows, RMA Manager, Web Servie, RCC).
Post Reply
evilmonkey
Posts: 6
Joined: Tue Jul 03, 2007 8:08 pm

How to return multiple lines from text log

Post by evilmonkey »

Hi,

I want to return n number of lines when we find an error in a text log. The parameters for the test includes number of words but this appears to be only to the EOL for the found text in an error. How do I do this?
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

Ther is CntLines utility available at www.ks-soft.net/download/utils/cntlines.exe
Usage:

Code: Select all

Usage:> cntlines.exe  <filename>  <search mode>  <limit>  <search string> 

Parameters: 
<filename>    - specify name of the file to check 

<search mode> - one of the following parameters: 
 -exact       - search for lines that exactly match specified <search string> 
 -start       - search for lines that begin with specified <search string> 
 -anywhere    - search for lines that contain specified <search string> 
 -total       - calculate total number of lines in the file. 

<limit>       - number of lines. If number of matched lines exceed specified 
                limit, utility will return "bad" status to HostMonitor. 
                Otherwise status is "Ok". 
                If specified file does not exist, utility returns "Unknown" 

<search str>  - string that you want to find in the file 
                if you are using -total search mode, skip this parameter 

Examples: 
 >cntlines.exe  c:\logs\log.txt  -start    100  "Error: " 
 >cntlines.exe  c:\webs\log.txt  -anywhere 999  "www.mycom" 
 >cntlines.exe  c:\text\log.txt  -total    500" 
You may use this utility with Shell Script test method
http://www.ks-soft.net/hostmon.eng/mfra ... m#chkShell

Regards
Alex
Post Reply