egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Count number of lines

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
BigToe
Halfop


Joined: 30 Dec 2010
Posts: 99

PostPosted: Sun Aug 19, 2012 12:20 am    Post subject: Count number of lines Reply with quote

hello, looking for a script then when typing !count filename it will count the number of lines of the filename (the file will be in scripts/ folder)

i.e.

!count Work.txt
<Bot> there are 14 lines in scripts\work.txt
Back to top
View user's profile Send private message
doggo
Halfop


Joined: 05 Jan 2010
Posts: 97

PostPosted: Mon Aug 20, 2012 5:00 pm    Post subject: Reply with quote

give this a try, not tested but should do the trick Wink

Code:
bind pub -|- !count count:numoflines

proc count:numoflines {nick host hand chan text} {

set fname [lindex [split $text] 0]
set loc "scripts"

#check file exists
if {![file exists $loc/$fname]} {
puthelp "PRIVMSG $chan :$loc/$fname does not exist.";return
}

#open file and count the lines
set file [open $loc/$fname "r"]
set nol 0
while {[gets $file line] >= 0} {
incr nol
}
close $file

#msg the channel
putserv "privmsg $chan :there are $nol lines in $loc/$fname"

}

_________________
NON geeky!! http://gotcode4u.com/
Back to top
View user's profile Send private message Visit poster's website
BigToe
Halfop


Joined: 30 Dec 2010
Posts: 99

PostPosted: Tue Aug 21, 2012 4:22 am    Post subject: Reply with quote

Works, thank you!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 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


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber