KS-Soft. Network Management Solutions
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister    ProfileProfile    Log inLog in 

Text Log test

 
Post new topic   Reply to topic    KS-Soft Forum Index -> Other
View previous topic :: View next topic  
Author Message
canish



Joined: 30 May 2007
Posts: 17
Location: TURKEY

PostPosted: Wed May 30, 2007 8:01 am    Post subject: Text Log test Reply with quote

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
Back to top
View user's profile Send private message
Yoorix



Joined: 14 Dec 2005
Posts: 177

PostPosted: Wed May 30, 2007 8:28 am    Post subject: Reply with quote

I think, you may use "Shell script" test method: http://www.ks-soft.net/hostmon.eng/mframe.htm#tests.htm#chkShell

You just have to write simple .bat file based on following command:
Code:
@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%


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
Back to top
View user's profile Send private message
canish



Joined: 30 May 2007
Posts: 17
Location: TURKEY

PostPosted: Wed May 30, 2007 8:33 am    Post subject: Reply with quote

Thanx for your help i have guessed that i have to use script.

thanks again for ur help
Back to top
View user's profile Send private message
KS-Soft Europe



Joined: 16 May 2006
Posts: 2832

PostPosted: Wed May 30, 2007 8:35 am    Post subject: Re: Text Log test Reply with quote

canish wrote:
i wonder how i can count the words occurences in the log file.

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.exe
Code:
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"


Utility is used within "Shell Script" test method: http://www.ks-soft.net/hostmon.eng/mframe.htm#tests.htm#chkShell

Regards,
Max
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    KS-Soft Forum Index -> Other All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group

KS-Soft Forum Index