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

	<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>2009-06-04T15:48:14-04:00</updated>

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

		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2009-06-04T15:48:14-04:00</updated>

		<published>2009-06-04T15:48:14-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=89095#p89095</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=89095#p89095"/>
		<title type="html"><![CDATA[FileReader]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=89095#p89095"><![CDATA[
Ahh, my apologies. Must have missed that.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Thu Jun 04, 2009 3:48 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[tomekk]]></name></author>
		<updated>2009-06-04T03:17:04-04:00</updated>

		<published>2009-06-04T03:17:04-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=89088#p89088</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=89088#p89088"/>
		<title type="html"><![CDATA[FileReader]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=89088#p89088"><![CDATA[
<blockquote class="uncited"><div>One thing strikes me, last_file_mod is not initialized upon startup, making the comparison "$last_file_mod != $file_mtime" possibly fail. I'd consider adding something like this to the script:<div class="codebox"><p>Code: </p><pre><code>if {![info exists ::last_file_mod]} {set ::last_file_mod 0}</code></pre></div></div></blockquote>it is initialized, before timer proc<div class="codebox"><p>Code: </p><pre><code>############################################################set last_file_mod 0</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10332">tomekk</a> — Thu Jun 04, 2009 3:17 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Slaktarn]]></name></author>
		<updated>2009-06-04T02:20:27-04:00</updated>

		<published>2009-06-04T02:20:27-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=89087#p89087</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=89087#p89087"/>
		<title type="html"><![CDATA[FileReader]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=89087#p89087"><![CDATA[
<blockquote class="uncited"><div>One thing strikes me, last_file_mod is not initialized upon startup, making the comparison "$last_file_mod != $file_mtime" possibly fail. I'd consider adding something like this to the script:<div class="codebox"><p>Code: </p><pre><code>if {![info exists ::last_file_mod]} {set ::last_file_mod 0}</code></pre></div></div></blockquote>How do you mean <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"> where shuld i edit it<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8963">Slaktarn</a> — Thu Jun 04, 2009 2:20 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2009-06-03T20:37:11-04:00</updated>

		<published>2009-06-03T20:37:11-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=89082#p89082</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=89082#p89082"/>
		<title type="html"><![CDATA[FileReader]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=89082#p89082"><![CDATA[
One thing strikes me, last_file_mod is not initialized upon startup, making the comparison "$last_file_mod != $file_mtime" possibly fail. I'd consider adding something like this to the script:<div class="codebox"><p>Code: </p><pre><code>if {![info exists ::last_file_mod]} {set ::last_file_mod 0}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Wed Jun 03, 2009 8:37 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[tomekk]]></name></author>
		<updated>2009-06-03T17:26:00-04:00</updated>

		<published>2009-06-03T17:26:00-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=89080#p89080</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=89080#p89080"/>
		<title type="html"><![CDATA[FileReader]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=89080#p89080"><![CDATA[
<blockquote class="uncited"><div>A suggestion, don't join the result from your lindex operation, as you're working on a list of strings (lindex returns the contained item, not a single-entity list).</div></blockquote>yeah, lame, my bad <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><br><br>i took again part of the source from the another script, there was [join [lrange .... ]] and i forgot, <br>anyway thank you<br><br>cheers !<br><br>@Slaktarn<br>yeah, fix it like <strong class="text-strong">nml375</strong> wrote and should be OK<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10332">tomekk</a> — Wed Jun 03, 2009 5:26 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Slaktarn]]></name></author>
		<updated>2009-06-03T13:33:34-04:00</updated>

		<published>2009-06-03T13:33:34-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=89074#p89074</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=89074#p89074"/>
		<title type="html"><![CDATA[FileReader]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=89074#p89074"><![CDATA[
<blockquote class="uncited"><div>It's because of the incorrect join I mentioned in my previous post.<div class="codebox"><p>Code: </p><pre><code>set last_line [join [lindex $get_data end]]###should beset last_line [lindex $get_data end]</code></pre></div></div></blockquote>Still not working but it send on .rehash<br>Working i guss<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8963">Slaktarn</a> — Wed Jun 03, 2009 1:33 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2009-06-03T13:31:45-04:00</updated>

		<published>2009-06-03T13:31:45-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=89073#p89073</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=89073#p89073"/>
		<title type="html"><![CDATA[FileReader]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=89073#p89073"><![CDATA[
It's because of the incorrect join I mentioned in my previous post.<div class="codebox"><p>Code: </p><pre><code>set last_line [join [lindex $get_data end]]###should beset last_line [lindex $get_data end]</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Wed Jun 03, 2009 1:31 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Slaktarn]]></name></author>
		<updated>2009-06-03T13:28:25-04:00</updated>

		<published>2009-06-03T13:28:25-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=89072#p89072</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=89072#p89072"/>
		<title type="html"><![CDATA[FileReader]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=89072#p89072"><![CDATA[
Hehe seems to work good but i got a strange error<br><br>[19:25] Tcl error in script for 'timer3':<br>[19:25] list element in quotes followed by ":" instead of space<br><br>I have try to search after it on googel but dident find mutch help<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8963">Slaktarn</a> — Wed Jun 03, 2009 1:28 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2009-06-03T09:46:46-04:00</updated>

		<published>2009-06-03T09:46:46-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=89062#p89062</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=89062#p89062"/>
		<title type="html"><![CDATA[FileReader]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=89062#p89062"><![CDATA[
A suggestion, don't join the result from your lindex operation, as you're working on a list of strings (lindex returns the contained item, not a single-entity list).<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Wed Jun 03, 2009 9:46 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[tomekk]]></name></author>
		<updated>2009-06-03T09:04:13-04:00</updated>

		<published>2009-06-03T09:04:13-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=89061#p89061</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=89061#p89061"/>
		<title type="html"><![CDATA[FileReader]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=89061#p89061"><![CDATA[
script is checking file mod time every X seconds, try it:<div class="codebox"><p>Code: </p><pre><code># tomekk, http://forum.egghelp.org/viewtopic.php?t=16929# output channelset out_chan "#channel" # fileset txt_file "myfile.txt" # check interval (seconds)set check_interval 10############################################################set last_file_mod 0proc reader_timer { } {global check_intervalauto_read_procif {[string match *reader_timer* [utimers]] != 1} {utimer $check_interval reader_timer}}proc auto_read_proc { } { global out_chan txt_file last_file_modset file_mtime [file mtime $txt_file]set file_handle [open $txt_file r]set get_data [split [read $file_handle] "\n"]close $file_handleset last_line [join [lindex $get_data end]]if {$last_line == ""} {set last_line [join [lindex $get_data end-1]]}if {$last_file_mod != $file_mtime} {putquick "PRIVMSG $out_chan :$last_line"set last_file_mod $file_mtime}}if {[string match *reader_timer* [utimers]] != 1} {utimer $check_interval reader_timer}putlog "auto-reader.tcl loaded"</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10332">tomekk</a> — Wed Jun 03, 2009 9:04 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2009-06-03T09:55:58-04:00</updated>

		<published>2009-06-03T06:42:30-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=89060#p89060</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=89060#p89060"/>
		<title type="html"><![CDATA[FileReader]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=89060#p89060"><![CDATA[
You could try to use the tail program along with pipes in tcl... Be wary of zombies though..<br><br>Code would look roughly like below. Be aware that this code depends on an external binary (tail).<div class="codebox"><p>Code: </p><pre><code>... set fid [open "| /urs/bin/tail -f /path/to/file" RDONLY] fconfigure $fid -blocking 0 -buffering line fileevent $fid readable [list readLine $fid]...proc readline {socket} { while {[gets $socket line] &gt;= 0} {  puthelp "PRIVMSG #channel :$line" } if {[eof $socket]} {  close $socket }}</code></pre></div>Edit:<br>On second thought, that code could easily be adopted to remove the need for the external binary:<div class="codebox"><p>Code: </p><pre><code>... set fid [open "/path/to/file" RDONLY] fconfigure $fid -blocking 0 -buffering line seek $fid 0 end fileevent $fid readable [list readLine $fid]...proc readline {socket} { while {[gets $socket line] &gt;= 0} {  puthelp "PRIVMSG #channel :$line" }}</code></pre></div><em class="text-italics">Fixed "seek"</em>.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Wed Jun 03, 2009 6:42 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Slaktarn]]></name></author>
		<updated>2009-06-03T05:46:31-04:00</updated>

		<published>2009-06-03T05:46:31-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=89059#p89059</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=89059#p89059"/>
		<title type="html"><![CDATA[FileReader]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=89059#p89059"><![CDATA[
<blockquote class="uncited"><div>not tested ;p, try:<div class="codebox"><p>Code: </p><pre><code>set out_chan "#channel"set txt_file "myfile.txt"bind pub -|- !read read_procproc read_proc { nick uhost hand chan arg } {        global out_chan txt_file        set take_me [open $txt_file r]        set take_all [split [read $take_me] "\n"]        close $take_me        foreach txt_line $take_all {                if {$txt_line != ""} {                        putquick "PRIVMSG $out_chan :$txt_line"                }        }}putlog "read.tcl blah blah ..."</code></pre></div></div></blockquote>Ths for the quick replay but i wuld like it to read like hmm last line every x second <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"> or if it possibel maybe everytime the file is changed automatic<br><br>Sorry its my fult i shuld be more clear tin the first post whit what i mean <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8963">Slaktarn</a> — Wed Jun 03, 2009 5:46 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[tomekk]]></name></author>
		<updated>2009-06-03T05:31:52-04:00</updated>

		<published>2009-06-03T05:31:52-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=89058#p89058</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=89058#p89058"/>
		<title type="html"><![CDATA[FileReader]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=89058#p89058"><![CDATA[
not tested ;p, try:<div class="codebox"><p>Code: </p><pre><code>set out_chan "#channel"set txt_file "myfile.txt"bind pub -|- !read read_procproc read_proc { nick uhost hand chan arg } {        global out_chan txt_file        set take_me [open $txt_file r]        set take_all [split [read $take_me] "\n"]        close $take_me        foreach txt_line $take_all {                if {$txt_line != ""} {                        putquick "PRIVMSG $out_chan :$txt_line"                }        }}putlog "read.tcl blah blah ..."</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10332">tomekk</a> — Wed Jun 03, 2009 5:31 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Slaktarn]]></name></author>
		<updated>2009-06-03T05:01:32-04:00</updated>

		<published>2009-06-03T05:01:32-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=89056#p89056</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=89056#p89056"/>
		<title type="html"><![CDATA[FileReader]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=89056#p89056"><![CDATA[
Just a sampel script that read from a txt file<br><br>and output #channel $text<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8963">Slaktarn</a> — Wed Jun 03, 2009 5:01 am</p><hr />
]]></content>
	</entry>
	</feed>
