Hi everyone
i want to add text log test but i need extra features that i can not handle. i am retrieving a log file from a database and i am looking for a word. this can be handled with text log test but there's a problem that the log file contains this word minimally 3 or 5 times that it could be sensible ato my test semantic. i wonder how i can count the words occurences in the log file.
Thanks for ur help
Text Log test
I think, you may use "Shell script" test method: http://www.ks-soft.net/hostmon.eng/mfra ... m#chkShell
You just have to write simple .bat file based on following command:
Instead of log_file.txt you have to specify full log file name and instead of "word_to_count" you have to specify exact word, you want to count occurences for.
Please note: such script is just an example and you may modify it on your own. For example, you may adjust script to pass parameters instead of hardcoded log_file.txt and "word_to_count" clauses.
--
Yoorix
You just have to write simple .bat file based on following command:
Code: Select all
@echo off
for /f "eol=; tokens=*" %%i in ('type log_file.txt ^| find /c "word_to_count"') do SET WordCount=%%i
echo SetRes:Ok:%WordCount%
Please note: such script is just an example and you may modify it on your own. For example, you may adjust script to pass parameters instead of hardcoded log_file.txt and "word_to_count" clauses.
--
Yoorix
-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact:
Re: Text Log test
You may use method, suggested by Yoorix or you may use our cntlines.exe utility, available at: http://www.ks-soft.net/download/utils/cntlines.execanish wrote:i wonder how i can count the words occurences in the log file.
Code: Select all
Usage:> cntlines.exe <filename> <search mode> <limit> <search string>
Options:
<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"
Regards,
Max