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

	<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>2012-06-10T11:30:00-04:00</updated>

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

		<entry>
		<author><name><![CDATA[willyw]]></name></author>
		<updated>2012-06-10T11:30:00-04:00</updated>

		<published>2012-06-10T11:30:00-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=99589#p99589</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=99589#p99589"/>
		<title type="html"><![CDATA[Read a line from file script]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=99589#p99589"><![CDATA[
<blockquote class="uncited"><div>Hey willyw,<br><br>You got it right... both times.. <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":-)" title="Smile"><br><br>Thanks a lot,</div></blockquote>You're welcome<br><blockquote class="uncited"><div> I apologize for earlier.</div></blockquote><img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile">   It's ok.  np<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10420">willyw</a> — Sun Jun 10, 2012 11:30 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Football]]></name></author>
		<updated>2012-06-10T11:24:08-04:00</updated>

		<published>2012-06-10T11:24:08-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=99588#p99588</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=99588#p99588"/>
		<title type="html"><![CDATA[Read a line from file script]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=99588#p99588"><![CDATA[
Hey willyw,<br><br>You got it right... both times.. <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":-)" title="Smile"><br><br>Thanks a lot, I apologize for earlier.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10393">Football</a> — Sun Jun 10, 2012 11:24 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[willyw]]></name></author>
		<updated>2012-06-10T10:46:06-04:00</updated>

		<published>2012-06-10T10:46:06-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=99587#p99587</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=99587#p99587"/>
		<title type="html"><![CDATA[Read a line from file script]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=99587#p99587"><![CDATA[
<blockquote class="uncited"><div>Yeah you're right, I apologize, its my fault.. I was thinking about something and wrote something else...</div></blockquote><img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_razz.gif" width="15" height="15" alt=":P" title="Razz"><br><blockquote class="uncited"><div> The script is meant to read each X minutes the next line in the file. Each time it reads a line, it erases that line from the file..</div></blockquote><br>Try this:<br><div class="codebox"><p>Code: </p><pre><code># June 10, 2012# http://forum.egghelp.org/viewtopic.php?t=19001######## Usage: To add a line, do:        !addline &lt;text of line here&gt;        in channel.#        To see all lines, do:  !sayfile# set how often file check runs - in minutesset sched 1# set path and filename of stats fileset statsfile "scripts/added/testing/Stats.txt"# set channels in which to announceset announcechans "#channel1 #channel2"bind pub - "!addline" addlinebind evnt - prerehash cleartimersbind pub - "!sayfile" sayfiletimer $sched readthefileproc readthefile { } {global sched statsfile announcechansif {![file exists $statsfile]} {timer $sched readthefilereturn 0         }# reference:  http://forum.egghelp.org/viewtopic.php?t=6885set fname $statsfileset fp [open $fname "r"]set data [read -nonewline $fp]close $fpset lines [split $data "\n"] if {[lindex $lines 0] == ""} {timer $sched readthefile           return 0        }foreach channel $announcechans {if {[botonchan $channel]} {putserv "privmsg $channel :[lindex $lines 0]"    }  }set fname $statsfileset fp [open $fname "r"]set data [read -nonewline $fp]close $fpset lines [split $data "\n"] # reference:  http://forum.egghelp.org/viewtopic.php?t=6885set line_to_delete 0set lines [lreplace $lines $line_to_delete $line_to_delete]set fp [open $fname "w"]puts $fp [join $lines "\n"]close $fp timer $sched readthefile}###proc cleartimers {prerehash} {foreach timerlisted [timers] {if {[lindex $timerlisted 1] == "readthefile" } {killtimer [lindex $timerlisted 2]              }   }}###proc addline {nick uhost handle chan text} {global statsfileif {$text == ""} {return 0         }# reference:   http://forum.egghelp.org/viewtopic.php?t=6885set line_to_add $textset fname $statsfileset fp [open $fname "a"]puts $fp $line_to_addclose $fp }###proc sayfile {nick uhost handle chan text} {global statsfileif {![file exists $statsfile]} {putserv "privmsg $chan :File does not exist"return 0         }set fname $statsfileset fp [open $fname "r"]set data [read -nonewline $fp]close $fpset lines [split $data "\n"]putserv "privmsg $chan :$lines"}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10420">willyw</a> — Sun Jun 10, 2012 10:46 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Football]]></name></author>
		<updated>2012-06-10T03:30:36-04:00</updated>

		<published>2012-06-10T03:30:36-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=99586#p99586</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=99586#p99586"/>
		<title type="html"><![CDATA[Read a line from file script]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=99586#p99586"><![CDATA[
Yeah you're right, I apologize, its my fault.. I was thinking about something and wrote something else... The script is meant to read each X minutes the next line in the file. Each time it reads a line, it erases that line from the file..<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10393">Football</a> — Sun Jun 10, 2012 3:30 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[willyw]]></name></author>
		<updated>2012-06-10T03:23:47-04:00</updated>

		<published>2012-06-10T03:23:47-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=99585#p99585</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=99585#p99585"/>
		<title type="html"><![CDATA[Read a line from file script]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=99585#p99585"><![CDATA[
<blockquote class="uncited"><div><br>However it seems that the script reads the first line from Stats.txt and then erases the whole txt, which isn't good.<br>[...]</div></blockquote><blockquote class="uncited"><div>... it will write the first line in the file to channel(s) set in the .tcl file and <em class="text-italics"><strong class="text-strong">erase that file</strong></em>. </div></blockquote>?<br>That's how I read your request.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10420">willyw</a> — Sun Jun 10, 2012 3:23 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Football]]></name></author>
		<updated>2012-06-10T02:38:23-04:00</updated>

		<published>2012-06-10T02:38:23-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=99584#p99584</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=99584#p99584"/>
		<title type="html"><![CDATA[Read a line from file script]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=99584#p99584"><![CDATA[
Hey willyw,<br><br>Thanks for the code<br><br>However it seems that the script reads the first line from Stats.txt and then erases the whole txt, which isn't good.<br><br>* Also wondering if you can please add a public command for adding lines to Stats.txt please<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10393">Football</a> — Sun Jun 10, 2012 2:38 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[willyw]]></name></author>
		<updated>2012-06-09T16:44:26-04:00</updated>

		<published>2012-06-09T16:44:26-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=99583#p99583</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=99583#p99583"/>
		<title type="html"><![CDATA[Re: Read a line from file script]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=99583#p99583"><![CDATA[
Experiment with this:<div class="codebox"><p>Code: </p><pre><code># June 9, 2012# http://forum.egghelp.org/viewtopic.php?t=19001## set how often file check runs - in minutesset sched 1# set path and filename of stats fileset statsfile "scripts/added/testing/Stats.txt"# set channels in which to announceset announcechans "#chan1 #chan2"##timer $sched readthefileproc readthefile { } {global sched statsfile announcechansif {![file exists $statsfile]} {timer $sched readthefilereturn 0         }# reference:  http://forum.egghelp.org/viewtopic.php?t=6885set fname $statsfileset fp [open $fname "r"]set data [read -nonewline $fp]close $fpset lines [split $data "\n"] if {[lindex $lines 0] == ""} {timer $sched readthefile           return 0        }foreach channel $announcechans {if {[botonchan $channel]} {putserv "privmsg $channel :[lindex $lines 0]"    }  }file delete $statsfiletimer $sched readthefile}bind evnt - prerehash cleartimersproc cleartimers {prerehash} {foreach timerlisted [timers] {if {[lindex $timerlisted 1] == "readthefile" } {killtimer [lindex $timerlisted 2]              }   }}</code></pre></div>Tested briefly, and it seemed to do what you described. I hope this helps.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10420">willyw</a> — Sat Jun 09, 2012 4:44 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Football]]></name></author>
		<updated>2012-06-09T11:40:10-04:00</updated>

		<published>2012-06-09T11:40:10-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=99580#p99580</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=99580#p99580"/>
		<title type="html"><![CDATA[Read a line from file script]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=99580#p99580"><![CDATA[
Hi all!<br><br>Was wondering if someone could help me out.<br><br>I need a script that will check every X minutes (determined in the script) if there are any lines written in a file called 'Stats.txt', if there is - it will write the first line in the file to channel(s) set in the .tcl file and erase that file.<br><br>If there are no lines in the file - it won't do anything, just keeping on checking the file and read/erase once there are lines in Stats.txt<br><br>Thanks<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10393">Football</a> — Sat Jun 09, 2012 11:40 am</p><hr />
]]></content>
	</entry>
	</feed>
