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

	<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>2008-12-16T15:45:49-04:00</updated>

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

		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2008-12-16T15:45:49-04:00</updated>

		<published>2008-12-16T15:45:49-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=86278#p86278</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=86278#p86278"/>
		<title type="html"><![CDATA[search a file delete a line]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=86278#p86278"><![CDATA[
The only limit is memory, as <strong class="text-strong">read</strong> will try to read as much data at once as possible from the file.<br><br>Although not a limit for the script, time might be a limit for your eggdrop, as while this script is processing, no other actions will be taken, possibly causing your eggdrop to ping timeout, etc..<br><br>For huge datasources, I'd suggest something like below. Keep in mind that this will only process one line per second, so filtering a huge file will take considerable time, however, since it's driven by timers, your eggdrop will remain responsive meanwhile. It also implements a simple filelock to prevent multiple filterings at once.<div class="codebox"><p>Code: </p><pre><code>proc StartFilter {File Pattern} { if {[info exists ::FilterLockfile] &amp;&amp; $::FilterLockfile == 1} {return 0} set ::FilterLockfile 1 set fIdRead [open "$File" "RDONLY"] while {[file exists [set tmpfile [file join ${temp-path} [randstring 8]]]]} {} set fIdWrite [open "$tmpfile" "WRONLY CREAT"] fconfigure $fIdRead -blocking 0 ProcessFile $fIdRead $fIdWrite $Pattern [list file rename -force -- $tmpfile $File]}proc ProcessFile {ReadFId WriteFId Pattern Cleanup} { if {[gets $ReadFId string] == -1 &amp;&amp; [eof $ReadFId]} {  close $ReadFId  close $WriteFId  eval $Cleanup  set ::FilterLockfile 0 } {  if {![string equal -nocase $Pattern [lindex [split $string] 0]]} {   puts $WriteFId $string  }  utimer 1 [list ProcessFile $ReadFId $WriteFId $Pattern $Cleanup] }}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Tue Dec 16, 2008 3:45 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[topdawg_b]]></name></author>
		<updated>2008-12-16T09:04:39-04:00</updated>

		<published>2008-12-16T09:04:39-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=86267#p86267</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=86267#p86267"/>
		<title type="html"><![CDATA[search a file delete a line]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=86267#p86267"><![CDATA[
shouldn't this line<br><blockquote class="uncited"><div>if {[lindex $delline 0] == "$criteria" &amp;&amp; [lindex $delline 0] != ""} { <br>   putlog "$delline" ;# if you see this is efcet in log !!!!! 1 !!!!!! <br>   puts $out1 "$delline" <br>  } </div></blockquote>actually be <blockquote class="uncited"><div>if {[lindex $delline 0] != "$criteria" &amp;&amp; [lindex $delline 0] != ""} { <br>   putlog "$delline" ;# if you see this is efcet in log !!!!! 1 !!!!!! <br>   puts $out1 "$delline" <br>  } <br></div></blockquote>in order to put the  non deleted info into the file?<br><br>are there any limits to using<br>set data [read $out] <br>set line [split $data \n] <br><br>would this  same method work if the  file had 5000 lines?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10347">topdawg_b</a> — Tue Dec 16, 2008 9:04 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[game_over]]></name></author>
		<updated>2008-12-15T08:19:23-04:00</updated>

		<published>2008-12-15T08:19:23-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=86248#p86248</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=86248#p86248"/>
		<title type="html"><![CDATA[search a file delete a line]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=86248#p86248"><![CDATA[
<div class="codebox"><p>Code: </p><pre><code>proc test:del {file num criteria} { ;# criteria is must ot be "word2" set out [open $file r] set data [read $out] set line [split $data \n] close $out set out1 [open $file w] ;# $out i use diferent names to w nad r    foreach delline $line {   if {[lindex $delline 0] == "$criteria" &amp;&amp; [lindex $delline 0] != ""} {   putlog "$delline" ;# if you see this is efcet in log !!!!! 1 !!!!!!   puts $out1 "$delline"  }} close $out1}</code></pre></div>!!!!! 1 !!!!!! -&gt;<br>word1 info about word 1<br>word3 info about word 3<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8946">game_over</a> — Mon Dec 15, 2008 8:19 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2008-12-13T21:17:36-04:00</updated>

		<published>2008-12-13T21:17:36-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=86231#p86231</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=86231#p86231"/>
		<title type="html"><![CDATA[search a file delete a line]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=86231#p86231"><![CDATA[
There are numerous approaches to do this.<br><br>Going with your first approach, you've determined the list offset of the wanted line. Having that, creating the new file would be a mere matter of using <strong class="text-strong">lreplace</strong> to replace (remove) the list item from the list, using <strong class="text-strong">join</strong> with a custom separator (similar, but the opposite, to <strong class="text-strong">split</strong>) to convert the new list to a string, and writing it to the new file.<br><br>A somewhat different approach, would be to read the file and convert it into a list (like before), but rather than using <strong class="text-strong">lsearch</strong>, simply use <strong class="text-strong">foreach</strong> to iterate through the whole list and test each item for the keyword, at the same time writing any non-matching line to the new file. This will provide more powerful tools for the matching, but will use more resources while running.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Sat Dec 13, 2008 9:17 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[topdawg_b]]></name></author>
		<updated>2008-12-13T07:00:41-04:00</updated>

		<published>2008-12-13T07:00:41-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=86226#p86226</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=86226#p86226"/>
		<title type="html"><![CDATA[search a file delete a line]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=86226#p86226"><![CDATA[
this is  what i came up with  while i was waiting. I am sure there are errors even though it seems to work. please advise on inproper syntax. thanks<br>where  test.ins has 3 lines in it<br>line 1<br>line 2<br>line 3<br>command = test:del file.ins 1<br>file becomes<br>line 1<br>line 3<br><div class="codebox"><p>Code: </p><pre><code>proc test:del {file num} { set out [open $file r] set data [read $out]  set line [split $data \n]  close $out set out [open $file w] set x 0  while {[lindex $line $x] != ""} {  if {$x != $num} {puts $out "[lindex $line $x]\r"}  incr x } close $out}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10347">topdawg_b</a> — Sat Dec 13, 2008 7:00 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[topdawg_b]]></name></author>
		<updated>2008-12-12T23:49:14-04:00</updated>

		<published>2008-12-12T23:49:14-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=86222#p86222</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=86222#p86222"/>
		<title type="html"><![CDATA[search a file delete a line]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=86222#p86222"><![CDATA[
I know how to use the lsearch command <br>not sure what you mean by renaming it  and replacing it.<br>this is  what I have so far<br>thestb would have the  "word2" in the exaple i gave<br><div class="codebox"><p>Code: </p><pre><code>set thestb [lindex $text 1]set in [open "triggers.txt" r] set data [read $in] set line [split $data \n] set here [lsearch [string tolower $line] "$thestb *"]</code></pre></div>thanks for the help[/code]<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10347">topdawg_b</a> — Fri Dec 12, 2008 11:49 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[vigilant]]></name></author>
		<updated>2008-12-12T22:57:18-04:00</updated>

		<published>2008-12-12T22:57:18-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=86221#p86221</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=86221#p86221"/>
		<title type="html"><![CDATA[search a file delete a line]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=86221#p86221"><![CDATA[
You delete it by  using lsearch function, renaming the file, and then replacing.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7195">vigilant</a> — Fri Dec 12, 2008 10:57 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[topdawg_b]]></name></author>
		<updated>2008-12-12T17:28:54-04:00</updated>

		<published>2008-12-12T17:28:54-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=86220#p86220</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=86220#p86220"/>
		<title type="html"><![CDATA[search a file delete a line]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=86220#p86220"><![CDATA[
I have a file it is a text file it's dedigned like this.<br><br>word1 info about  word 1<br>word2 info about word 2<br>word3 info about word 3<br><br>the file is called trigger.txt<br><br>i want to delete a line.   like seek out word2 if the text line begins with word2, delete that whole line. leaving the file<br><br>word1 info about  word 1<br>word3 info about word 3<br><br>what is the most effecient wat of doing this?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10347">topdawg_b</a> — Fri Dec 12, 2008 5:28 pm</p><hr />
]]></content>
	</entry>
	</feed>
