This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Count number of lines

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
B
BigToe
Halfop
Posts: 99
Joined: Thu Dec 30, 2010 4:49 pm

Count number of lines

Post by BigToe »

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
d
doggo
Halfop
Posts: 97
Joined: Tue Jan 05, 2010 7:53 am
Contact:

Post by doggo »

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

Code: Select all

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"

}
B
BigToe
Halfop
Posts: 99
Joined: Thu Dec 30, 2010 4:49 pm

Post by BigToe »

Works, thank you!
Post Reply