<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forum.eggheads.org/app.php/feed/topic/3290" />

	<title>egghelp/eggheads community</title>
	<subtitle>Discussion of eggdrop bots, shell accounts and tcl scripts.</subtitle>
	<link href="https://forum.eggheads.org/index.php" />
	<updated>2002-12-29T14:46:15-04:00</updated>

	<author><name><![CDATA[egghelp/eggheads community]]></name></author>
	<id>https://forum.eggheads.org/app.php/feed/topic/3290</id>

		<entry>
		<author><name><![CDATA[strikelight]]></name></author>
		<updated>2002-12-29T14:46:15-04:00</updated>

		<published>2002-12-29T14:46:15-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=14669#p14669</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=14669#p14669"/>
		<title type="html"><![CDATA[Re: Counting the lines in a file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=14669#p14669"><![CDATA[
<blockquote class="uncited"><div>Why not just do the following?<div class="codebox"><p>Code: </p><pre><code>set filelength [exec cat $filename | wc -l]</code></pre></div></div></blockquote>And not all systems "need" to have 'cat' or 'wc' commands. (ie. Windows).<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2005">strikelight</a> — Sun Dec 29, 2002 2:46 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[egghead]]></name></author>
		<updated>2002-12-28T12:19:05-04:00</updated>

		<published>2002-12-28T12:19:05-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=14649#p14649</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=14649#p14649"/>
		<title type="html"><![CDATA[Re: Counting the lines in a file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=14649#p14649"><![CDATA[
<blockquote class="uncited"><div>Why not just do the following?<div class="codebox"><p>Code: </p><pre><code>set filelength [exec cat $filename | wc -l]</code></pre></div></div></blockquote>On the shell system I'm using "[exec cat $filename | wc -l]" is about 15 times as slow as the "open/read/close/split/llength".<br>Your suggestion can be improved a bit by using [exec wc -l $filename], but it is still a factor 10 slower.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=282">egghead</a> — Sat Dec 28, 2002 12:19 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2002-12-28T11:55:30-04:00</updated>

		<published>2002-12-28T11:55:30-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=14648#p14648</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=14648#p14648"/>
		<title type="html"><![CDATA[Counting the lines in a file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=14648#p14648"><![CDATA[
Why not just do the following?<div class="codebox"><p>Code: </p><pre><code>set filelength [exec cat $filename | wc -l]</code></pre></div><p>Statistics: Posted by Guest — Sat Dec 28, 2002 11:55 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[strikelight]]></name></author>
		<updated>2002-12-22T00:55:05-04:00</updated>

		<published>2002-12-22T00:55:05-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=14490#p14490</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=14490#p14490"/>
		<title type="html"><![CDATA[Counting the number of lines in a file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=14490#p14490"><![CDATA[
<blockquote class="uncited"><div>I have sorted the problem now:<br><blockquote class="uncited"><div>proc msg_listpassreqs {nick uhost hand args} {<br> global botnick requestpassfile<br> set fileread [open $requestpassfile r]<br> set all [read $fileread]<br> close $fileread<br> if { $all == "" } {<br>  putnotc $nick "Error: No password requests pending"<br>  return 0<br>  }<br> set number 0<br> foreach count [split $all \n] {<br>  incr number<br>  }<br> putnotc $nick "There are [expr $number-1] password requests pending"<br> foreach line [split $all \n] {<br>  puthelp "NOTICE $nick :$line"<br>  }<br>}</div></blockquote></div></blockquote>just a tip, since you are converting "all" to a list delimited by \n, you might want to use llength to save iterations/cpu cycles.  (ie. set number [llength [split $all \n]])<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2005">strikelight</a> — Sun Dec 22, 2002 12:55 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[simonbell]]></name></author>
		<updated>2002-12-21T21:55:55-04:00</updated>

		<published>2002-12-21T21:55:55-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=14487#p14487</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=14487#p14487"/>
		<title type="html"><![CDATA[Counting the number of lines in a file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=14487#p14487"><![CDATA[
I have sorted the problem now:<br><blockquote class="uncited"><div>proc msg_listpassreqs {nick uhost hand args} {<br> global botnick requestpassfile<br> set fileread [open $requestpassfile r]<br> set all [read $fileread]<br> close $fileread<br> if { $all == "" } {<br>  putnotc $nick "Error: No password requests pending"<br>  return 0<br>  }<br> set number 0<br> foreach count [split $all \n] {<br>  incr number<br>  }<br> putnotc $nick "There are [expr $number-1] password requests pending"<br> foreach line [split $all \n] {<br>  puthelp "NOTICE $nick :$line"<br>  }<br>}</div></blockquote><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=1696">simonbell</a> — Sat Dec 21, 2002 9:55 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[simonbell]]></name></author>
		<updated>2002-12-21T21:10:16-04:00</updated>

		<published>2002-12-21T21:10:16-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=14484#p14484</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=14484#p14484"/>
		<title type="html"><![CDATA[Counting the number of lines in a file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=14484#p14484"><![CDATA[
hm actually, i just put a putlog "test" underneath 'foreach line [gets $fs] {' and it resulted in repeating 'test' 16 times. I have looked at the file manually and it only has 1 line in it...<br><br>Simon<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=1696">simonbell</a> — Sat Dec 21, 2002 9:10 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[tainted]]></name></author>
		<updated>2002-12-21T20:35:21-04:00</updated>

		<published>2002-12-21T20:35:21-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=14482#p14482</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=14482#p14482"/>
		<title type="html"><![CDATA[Counting the number of lines in a file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=14482#p14482"><![CDATA[
Are you sure its reading the file correctly? Try adding a putlog $line or another debug way to actually see what its counting. Off of the top of my head, I would have to say that script appears to be correct.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=1256">tainted</a> — Sat Dec 21, 2002 8:35 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[simonbell]]></name></author>
		<updated>2002-12-21T14:56:42-04:00</updated>

		<published>2002-12-21T14:56:42-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=14475#p14475</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=14475#p14475"/>
		<title type="html"><![CDATA[Counting the number of lines in a file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=14475#p14475"><![CDATA[
I am trying to count the number of lines in a file. The script i have so far is:<br><blockquote class="uncited"><div>set number 0<br> set fs [open $requestpassfile r]<br> while {![eof $fs]} {<br>  foreach line [gets $fs] {<br>   set count [expr $number+1]<br>   }<br>  }<br> close $fs<br> putnotc $nick "There are $count password requests pending"</div></blockquote>this script doesnt work though, it only ever says there are 1 lines in the file.<br><br>what am i doing wrong?<br><br>thanks<br>Simon<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=1696">simonbell</a> — Sat Dec 21, 2002 2:56 pm</p><hr />
]]></content>
	</entry>
	</feed>
