<?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/2754" />

	<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-10-12T14:53:15-04:00</updated>

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

		<entry>
		<author><name><![CDATA[darko``]]></name></author>
		<updated>2002-10-12T14:53:15-04:00</updated>

		<published>2002-10-12T14:53:15-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=11925#p11925</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=11925#p11925"/>
		<title type="html"><![CDATA[reading lines from a file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=11925#p11925"><![CDATA[
Kernel will not allow what you want. File has to be rewritten completely. A simple<br><br>set readfd [open file r]<br>set writefd [open file.tmp w]<br>while (1) {<br>  set blah [gets $readfd]<br>  if {[eof $readfd]} { break }<br>  if {$blah not match something} {puts $writefd $blah}<br>}<br>close $writefd<br>close $readfd<br>mv file.tmp file<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=1881">darko``</a> — Sat Oct 12, 2002 2:53 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[simonbell]]></name></author>
		<updated>2002-10-12T11:16:20-04:00</updated>

		<published>2002-10-12T11:16:20-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=11913#p11913</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=11913#p11913"/>
		<title type="html"><![CDATA[reading lines from a file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=11913#p11913"><![CDATA[
that worked thanks.<br><br>Now i am trying to search through the same file for a specific handle. The handle will be found at [lindex $arg 10] on each line. I could obviously use the same method of reading the whole file then going through each line and checking whether what i input is the same as $arg 10. But once i find that, how would i find which line number in the file this match occurs at, and how do i then tell it to remove the line from the file altogether, i cant seem to find the last part about removing lines in the tutorial ive been going through. Or would i have to employ a different method altogether?<br><br>~ Simon<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=1696">simonbell</a> — Sat Oct 12, 2002 11:16 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ppslim]]></name></author>
		<updated>2002-10-12T10:27:44-04:00</updated>

		<published>2002-10-12T10:27:44-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=11909#p11909</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=11909#p11909"/>
		<title type="html"><![CDATA[reading lines from a file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=11909#p11909"><![CDATA[
IRC servers use a \n to signify the end of a command.<br><br>As such, the read command reads all available data, int he case of a file, the whole file.<br><br>This ifnormation will include the \n's. As uch,t he IRC server will barf error for each line that isn't prepended with the command.<br><br>Thus, you need to split the input from read (using split), to create list (use \n as the split character). Then you can cycle through each element in the list, using foreach, and output it to the user the correct way.<br><br>something like<div class="codebox"><p>Code: </p><pre><code>foreach line [split [read $filepointer] \n] {  puthelp "PRIVMSG $chan :$line"}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2">ppslim</a> — Sat Oct 12, 2002 10:27 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[simonbell]]></name></author>
		<updated>2002-10-12T10:15:28-04:00</updated>

		<published>2002-10-12T10:15:28-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=11908#p11908</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=11908#p11908"/>
		<title type="html"><![CDATA[reading lines from a file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=11908#p11908"><![CDATA[
i am actually already using this code:<br><blockquote class="uncited"><div>proc msg_listpassreqs {nick uhost hand args} {<br> global botnick requestpassfile<br> putnotc $nick "Listing Password Requests"<br> set fileread [open $requestpassfile r]<br> set all [read $fileread]<br> close $fileread<br> puthelp "NOTICE $nick :$all"<br>}</div></blockquote>which is pretty similar. It obviously knows where the file is because it reads at least one line from it. However, it does not read more than one line, eg.<br><blockquote class="uncited"><div>-H4- Listing Password Requests<br>-H4- 1032646114 notbad <a href="mailto:aooi58@usercf098.dsl.pipex.com">aooi58@usercf098.dsl.pipex.com</a> bob <a href="mailto:a@b.com">a@b.com</a> *****</div></blockquote>is all it outputs when i know there are 4 lines in the file to read, and if i replace notice with putlog, all 4 lines are output.<br><br>Simon<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=1696">simonbell</a> — Sat Oct 12, 2002 10:15 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[spyda]]></name></author>
		<updated>2002-10-12T10:05:51-04:00</updated>

		<published>2002-10-12T10:05:51-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=11906#p11906</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=11906#p11906"/>
		<title type="html"><![CDATA[This might help.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=11906#p11906"><![CDATA[
To start with you need to set where the file is on the box<br><div class="codebox"><p>Code: </p><pre><code>set file "/path/to/where/it/is"</code></pre></div>That will tell the eggdrop where the file is located, and is set to a global value but can also be done within the script too.<br><br>Next is to open the file read the data and set it in a string so that you can send the infomation to anyone or use it to find out something else.<br><div class="codebox"><p>Code: </p><pre><code>set open_file [open $file/$filename.txt r]set read_info [read $open_file]</code></pre></div>Now all the findo that was located in $filename.txt in set into value $read_info. For there you can do many things with it. For what you are after here is a simple soulation.<br><div class="codebox"><p>Code: </p><pre><code>puthelp "NOTICE $nick :$read_info"</code></pre></div>Now to write a little tcl to work it all, you would make it a little like this.<br><div class="codebox"><p>Code: </p><pre><code>set asus(file) "/eggdrop/scripts"bind MSG - text asus_text proc asus_text {nick uhost hand vasus} {  global asus  set asus_open [open $asus(file)/text.txt r]  set asus_read [read $asus_open]  close $asus_open  puthelp "NOTICE $nick :$asus_read"}</code></pre></div>Have fun<br><br>------------<br>ThePope<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=1731">spyda</a> — Sat Oct 12, 2002 10:05 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[simonbell]]></name></author>
		<updated>2002-10-12T09:32:10-04:00</updated>

		<published>2002-10-12T09:32:10-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=11902#p11902</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=11902#p11902"/>
		<title type="html"><![CDATA[reading lines from a file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=11902#p11902"><![CDATA[
ok so when i output the whole file using read and i put it into a "putlog" it outputs<br><blockquote class="uncited"><div>&lt;h4&gt; [14:28] bell_dead 1032646114 ****** <a href="mailto:aooi58@usercf098.dsl.pipex.com">aooi58@usercf098.dsl.pipex.com</a> bob <a href="mailto:a@b.com">a@b.com</a> ******<br>&lt;h4&gt; 1034099624 bob <a href="mailto:aooi58@usercf098.dsl.pipex.com">aooi58@usercf098.dsl.pipex.com</a> moo <a href="mailto:aooi58@dsl.pipex.com">aooi58@dsl.pipex.com</a> ******<br>&lt;h4&gt; Submitted: 1034432741 Nick: bell_dead Address: <a href="mailto:aooi58@usercf098.dsl.pipex.com">aooi58@usercf098.dsl.pipex.com</a> Handle: test3 RegEmail: <a href="mailto:a@b.com">a@b.com</a> NewPass: ******<br>&lt;h4&gt; Submitted: Thu Jan  1 00:00:00 1970 Nick: bell_dead Address: <a href="mailto:aooi58@usercf098.dsl.pipex.com">aooi58@usercf098.dsl.pipex.com</a> Handle: test2 RegEmail: <a href="mailto:a@b.com">a@b.com</a> NewPass: ******</div></blockquote>however, when i put it into a notice to the user, only the first line is output to the user. How can i rectify this?<br><br>Simon<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=1696">simonbell</a> — Sat Oct 12, 2002 9:32 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ppslim]]></name></author>
		<updated>2002-10-08T17:23:03-04:00</updated>

		<published>2002-10-08T17:23:03-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=11816#p11816</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=11816#p11816"/>
		<title type="html"><![CDATA[reading lines from a file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=11816#p11816"><![CDATA[
You are testing for an eof, before it can occur.<br><br>EG.<br><br>1 Line in a file. The order the code is done.<br><br>Open file<br>Is file EOF<br>No, then read line 1<br>Output line 1<br>Loop<br>Is file EOF<br>No, read line 2. File is EOF, set EOF flag<br>Output line 2 (blank data)<br>Loop<br>Is file EOF<br>Yes, exit loop.<br><br>The EOF status is not set, until read or gets receives it.<br><br>A better method is to forget the while loop for reading the file.<br><br>Use read, to grab the whole of the file, so it can be closed right away, without worrying about EOF.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2">ppslim</a> — Tue Oct 08, 2002 5:23 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[simonbell]]></name></author>
		<updated>2002-10-08T13:35:13-04:00</updated>

		<published>2002-10-08T13:35:13-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=11804#p11804</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=11804#p11804"/>
		<title type="html"><![CDATA[reading lines from a file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=11804#p11804"><![CDATA[
Hi<br><br>i have a script which reads all the lines from a file and outputs them:<br><blockquote class="uncited"><div>proc msg_listpassreqs {nick uhost hand arg} {<br> global botnick requestpassfile<br> putnotc $nick "Listing Password Requests"<br> set fileread [open $requestpassfile r]<br> while {![eof $fileread] } {<br>  foreach listing [gets $fileread line] {<br>   set subtime [lindex $line 0]<br>   set subnick [lindex $line 1]<br>   set uhost [lindex $line 2]<br>   set handle [lindex $line 3]<br>   set regemail [lindex $line 4]<br>   set newpass [lindex $line 5]<br>   putlog "Submitted: \[Time:\] [ctime $subtime] \[Nick:\] $subnick \[Uhost:\] $uhost \[Handle:\] $hand \[RegEmail:\] $regemail \[NewPass:\] $newpass"<br>   }<br>  }<br> close $fileread<br>}</div></blockquote>This does work, and outputs the 2 lines of information in the file, but with one problem:<br><blockquote class="uncited"><div>&lt;h4&gt; [18:38] Submitted: [Time:] Sat Sep 21 22:08:34 2002 [Nick:] notbad [Uhost:] <a href="mailto:aooi58@usercf098.dsl.pipex.com">aooi58@usercf098.dsl.pipex.com</a> [Handle:] Simon [RegEmail:] <a href="mailto:a@b.com">a@b.com</a> [NewPass:] test<br>&lt;h4&gt; [18:38] Submitted: [Time:] Tue Oct  8 17:53:44 2002 [Nick:] bob [Uhost:] <a href="mailto:aooi58@usercf098.dsl.pipex.com">aooi58@usercf098.dsl.pipex.com</a> [Handle:] Simon [RegEmail:] <a href="mailto:aooi58@dsl.pipex.com">aooi58@dsl.pipex.com</a> [NewPass:] test<br>&lt;h4&gt; [18:38] Submitted: [Time:] Thu Jan  1 00:00:00 1970 [Nick:]  [Uhost:]  [Handle:] Simon [RegEmail:]  [NewPass:] </div></blockquote>What am i doing wrong which is making it produce the bottom line?<br><br>thanks<br>Simon<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=1696">simonbell</a> — Tue Oct 08, 2002 1:35 pm</p><hr />
]]></content>
	</entry>
	</feed>
