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

count line in a file

 
Post new topic   Reply to topic    KS-Soft Forum Index -> Wish list
View previous topic :: View next topic  
Author Message
y.beyet



Joined: 16 Apr 2002
Posts: 62
Location: France

PostPosted: Tue Feb 21, 2006 5:22 am    Post subject: count line in a file Reply with quote

Hello Alex,

I need to count the number of lines that contain a string in a file. I've a script making this but I think it could be easy to add this feature to the test log.

Regards,

Yannig
Back to top
View user's profile Send private message Visit poster's website
KS-Soft



Joined: 03 Apr 2002
Posts: 12817
Location: USA

PostPosted: Tue Feb 21, 2006 11:31 am    Post subject: Reply with quote

Text Log test checks for NEW records only. If you need to calculate all occurence of the string, Compare Files test is more suitable...
You want to start alert when file contains more or less than specified number of strings?

Regards
Alex
Back to top
View user's profile Send private message Visit poster's website
y.beyet



Joined: 16 Apr 2002
Posts: 62
Location: France

PostPosted: Fri Feb 24, 2006 6:32 am    Post subject: Reply with quote

Yes !
It's a daily mailing log file. I have to make statistics to a specified domain by countings all the lines matching my pattern.
Back to top
View user's profile Send private message Visit poster's website
KS-Soft



Joined: 03 Apr 2002
Posts: 12817
Location: USA

PostPosted: Fri Feb 24, 2006 11:38 am    Post subject: Reply with quote

Such check may need various options, so its good task for new test method.
H'm.. If I have time today, I create command line utility that can be used for Shell Script test method

Regards
Alex
Back to top
View user's profile Send private message Visit poster's website
KS-Soft



Joined: 03 Apr 2002
Posts: 12817
Location: USA

PostPosted: Fri Feb 24, 2006 12:28 pm    Post subject: Reply with quote

Ok, utility available at www.ks-soft.net/download/cntlines.exe
Usage:
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"


Regards
Alex
Back to top
View user's profile Send private message Visit poster's website
y.beyet



Joined: 16 Apr 2002
Posts: 62
Location: France

PostPosted: Mon Feb 27, 2006 9:47 am    Post subject: Reply with quote

Sorry,

I need to calculate total number of lines in the file matching a string...

Thank you for your work...
Back to top
View user's profile Send private message Visit poster's website
Yoorix



Joined: 14 Dec 2005
Posts: 177

PostPosted: Mon Feb 27, 2006 10:28 am    Post subject: Reply with quote

[quote='y.beyet']
I need to calculate total number of lines in the file matching a string...[/quote]

I am not sure I understand, do you mean filename should match the string?

Regards,
Yoorix
Back to top
View user's profile Send private message
KS-Soft



Joined: 03 Apr 2002
Posts: 12817
Location: USA

PostPosted: Mon Feb 27, 2006 11:53 am    Post subject: Reply with quote

I do not understand either
Before you said "I need to count the number of lines that contain a string in a file."

Regards
Alex
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    KS-Soft Forum Index -> Wish list 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