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

	<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>2010-03-25T13:09:37-04:00</updated>

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

		<entry>
		<author><name><![CDATA[raider2k]]></name></author>
		<updated>2010-03-25T13:09:37-04:00</updated>

		<published>2010-03-25T13:09:37-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=92603#p92603</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=92603#p92603"/>
		<title type="html"><![CDATA[[SOLVED] catch errors, dont make eggy die]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=92603#p92603"><![CDATA[
k-meleon here ^^<br>and yup, thats probably why then, weird things are happening on the internet lol<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9589">raider2k</a> — Thu Mar 25, 2010 1:09 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2010-03-25T10:24:07-04:00</updated>

		<published>2010-03-25T10:24:07-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=92602#p92602</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=92602#p92602"/>
		<title type="html"><![CDATA[[SOLVED] catch errors, dont make eggy die]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=92602#p92602"><![CDATA[
Ahh, one more converted  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_wink.gif" width="15" height="15" alt=";)" title="Wink"><br><br>I believe those spaces were due to your browser; I've seen some browsers adding them on the fly, while others (like mine) don't. Unfortunately, it becomes a somewhat complicated structure when you want to do it proper, yet have one item per line.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Thu Mar 25, 2010 10:24 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[raider2k]]></name></author>
		<updated>2010-03-25T01:38:30-04:00</updated>

		<published>2010-03-25T01:38:30-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=92600#p92600</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=92600#p92600"/>
		<title type="html"><![CDATA[[SOLVED] catch errors, dont make eggy die]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=92600#p92600"><![CDATA[
well, know what? lol<br><br>i put a space after \ because of two reasons:<br><br>1. it seemed quite logic to me to escape a space char with \ so its really being treated as one<br><br>2. try to select that code of yours with your mouse and you'll notice that \[code\] puts a space after the \<br><br>plus, i made an important mistake, i didnt put a \ after the first line that contains "set scripts [list"<br><br>but wow .. im impressed because everything is working again and the mistakes were more of a minor matter. thx again for help <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"> (cant say that often enough ^^)<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9589">raider2k</a> — Thu Mar 25, 2010 1:38 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2010-03-24T17:41:42-04:00</updated>

		<published>2010-03-24T17:41:42-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=92594#p92594</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=92594#p92594"/>
		<title type="html"><![CDATA[[SOLVED] catch errors, dont make eggy die]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=92594#p92594"><![CDATA[
The code still expects the supplied data to be a list, so using a string with the loadscript proc would still be "improper". Still, as long as you're very careful, you'll be safe. <br><br>The list commands used with uplevel (since user's fix) is used to avoid something known as double-evaluation, it does not affect the data passed to the foreach command, which still has to be a valid list.<br><br>The problem you are facing with "set scripts [list ... ]" is that you don't properly escape the newline character using \<br>Wrong:<div class="codebox"><p>Code: </p><pre><code>set scripts [listscripts/script1.tclscripts/script2.tclscripts/script3.tcl]</code></pre></div>Correct:<div class="codebox"><p>Code: </p><pre><code>set scripts [list \scripts/script1.tcl \scripts/script2.tcl \scripts/script3.tcl \]</code></pre></div>It is vital that there is no space or other charactes after the \ before the newline.<br><br>Whenever a string is evaluated (in this case due to []), a newline means end of command-line, and the first word on the next line is treated as a new command. Escaping the newline prevents this, and lets us span a single command-line over several lines.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Wed Mar 24, 2010 5:41 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[raider2k]]></name></author>
		<updated>2010-03-24T12:53:46-04:00</updated>

		<published>2010-03-24T12:53:46-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=92590#p92590</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=92590#p92590"/>
		<title type="html"><![CDATA[[SOLVED] catch errors, dont make eggy die]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=92590#p92590"><![CDATA[
W O N D E R F U L L <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_biggrin.gif" width="15" height="15" alt=":D" title="Very Happy"><br><br>because right now i wanted to ask why its coming up with some errors here and there, i think missing uplevel was the answer to that not-yet-asked-question <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><br><br>thx again for help, thx to both of you <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><br><br>btw: since the loadsource proc does a list on script from foreach scripts, am i safe to use set scripts { .... } now? im still a bit confused regarding that as i want to put each script into its own line, starting from the very first line until the last one, "set scripts [list" into the line before the first and "]" into the line after the last one. doing this now results in an error telling me that bot doesnt understand command "scripts/reg.tcl"<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9589">raider2k</a> — Wed Mar 24, 2010 12:53 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2010-03-24T11:08:15-04:00</updated>

		<published>2010-03-24T11:08:15-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=92588#p92588</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=92588#p92588"/>
		<title type="html"><![CDATA[[SOLVED] catch errors, dont make eggy die]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=92588#p92588"><![CDATA[
Nice catch, user. I'll update my post in a minute or so..<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Wed Mar 24, 2010 11:08 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[user]]></name></author>
		<updated>2010-03-24T04:12:38-04:00</updated>

		<published>2010-03-24T04:12:38-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=92586#p92586</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=92586#p92586"/>
		<title type="html"><![CDATA[[SOLVED] catch errors, dont make eggy die]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=92586#p92586"><![CDATA[
<blockquote class="uncited"><div><div class="codebox"><p>Code: </p><pre><code>if {[catch {source $script} err]} {</code></pre></div></div></blockquote>You are invoking 'source' in the scope of the proc, which means the code inside the sourced files is also executed in this scope. ("global" variables become local to the proc etc.) Use 'uplevel' to have it invoked in the right scope: <div class="codebox"><p>Code: </p><pre><code>if {[catch [list uplevel #0 [list source $script]] err]} {</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2878">user</a> — Wed Mar 24, 2010 4:12 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[raider2k]]></name></author>
		<updated>2010-03-23T13:22:46-04:00</updated>

		<published>2010-03-23T13:22:46-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=92580#p92580</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=92580#p92580"/>
		<title type="html"><![CDATA[[SOLVED] catch errors, dont make eggy die]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=92580#p92580"><![CDATA[
mhm, i think now i know what you mean <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><br>very interesting, i hope ill keep that in mind <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_biggrin.gif" width="15" height="15" alt=":D" title="Very Happy"><br>thx nml ^^<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9589">raider2k</a> — Tue Mar 23, 2010 1:22 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2010-03-23T09:06:01-04:00</updated>

		<published>2010-03-23T09:06:01-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=92579#p92579</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=92579#p92579"/>
		<title type="html"><![CDATA[[SOLVED] catch errors, dont make eggy die]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=92579#p92579"><![CDATA[
Ahh, sorry.<br>I guess the simplest way of putting it is this:<br>Whenever a command expects a parameter value to be a list, make sure you are providing a list - not a string.<br>The simplest way of creating a list, is either to use the list command - or to split a string into a list. If you try to handcraft lists, you're bound to run into trouble sooner or later.<br><br>Oh, and regarding the examples in the previous post:<br>The first example demonstrates an improper script where I 'get away' with it because my string resembles a list well enough for tcl to understand it.<br>The second extends the improper scripting by accepting 'untrusted data' as a list - and it appears to work in most cases. Except in some non-trivial cases, where the script all of a sudden seems to stop working.<br><br>Your script is similar to example 1 right now. The step to something like example 2 isn't that far away...<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Tue Mar 23, 2010 9:06 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[raider2k]]></name></author>
		<updated>2010-03-23T00:45:57-04:00</updated>

		<published>2010-03-23T00:45:57-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=92576#p92576</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=92576#p92576"/>
		<title type="html"><![CDATA[[SOLVED] catch errors, dont make eggy die]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=92576#p92576"><![CDATA[
i think ... im confused right now  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_eek.gif" width="15" height="15" alt=":shock:" title="Shocked"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9589">raider2k</a> — Tue Mar 23, 2010 12:45 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2010-03-22T15:50:18-04:00</updated>

		<published>2010-03-22T15:50:18-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=92570#p92570</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=92570#p92570"/>
		<title type="html"><![CDATA[[SOLVED] catch errors, dont make eggy die]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=92570#p92570"><![CDATA[
The improper thing is that you are handling a string as if it was a list. You can craft strings that tcl manages to interpret as lists, though it still is a string. For trivial list elements, this is fairly easy, but simply adding a space into the element makes it non-trivial. If you're not careful, it'll catch you offguard, giving you a nice headache.. Or if you use this with a Windows-style filesystem (using \ instead of /}).<br><br>You can indeed use split to convert a string into a proper list, and using lindex on a string is technically the same improper issue. However, "split $text" would often be used when the content of $text comes from a remote user, where you have no control what-so-ever of it's original content (hence you cannot quarantee it to be a valid list structure).<br><br>Actually, that's quite a good example how "sloppy" coding might sneak up and stab you in the back.. You get comfortable using something like this:<div class="codebox"><p>Code: </p><pre><code>set keywords "hello dolly"foreach key $keywords {  bind msg - $key msg:hello}</code></pre></div>This is not proper, but since we're dealing with trivial elements, we get away with it - in fact, if we didn't read the manpages for foreach, we could come to believe that this will add a binding for each word of $keywords. We might even use it when writing a script to add multiple users to the bots userlist:<div class="codebox"><p>Code: </p><pre><code>proc addusers {handle idx text} {  foreach user $text {    if {[adduser $user [hostmask $user![getchanhost $user]]]} {      setuser $user PASS $user    }  }}</code></pre></div>It works well in a few simple tests... then you want to add someone named {badboy{ ... Now it doesn't work anymore, and you don't understand why it fails all of a sudden...<br>The solution here, is to use split to convert the string into a proper list.<br><br><br><em class="text-italics">To put it very simple, the difference between your code and mine, is that I use the list command to let tcl build a list, while you craft something resembling a list well enough for tcl to understand it.</em><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Mon Mar 22, 2010 3:50 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[raider2k]]></name></author>
		<updated>2010-03-22T13:21:14-04:00</updated>

		<published>2010-03-22T13:21:14-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=92568#p92568</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=92568#p92568"/>
		<title type="html"><![CDATA[[SOLVED] catch errors, dont make eggy die]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=92568#p92568"><![CDATA[
ok, im always interested in becoming better, its just not clear enough to me what exactly i wasnt doing so properly.<br><br>is it about those " \ "'s ? if you dont mind please post me an example based on my code, i think that would help me out <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><br><br>btw: i also remember you telling me to use split $text before i lindex it in another post some time ago, still remember and also using it <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_wink.gif" width="15" height="15" alt=";)" title="Wink"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9589">raider2k</a> — Mon Mar 22, 2010 1:21 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2010-03-22T13:09:35-04:00</updated>

		<published>2010-03-22T13:09:35-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=92567#p92567</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=92567#p92567"/>
		<title type="html"><![CDATA[[SOLVED] catch errors, dont make eggy die]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=92567#p92567"><![CDATA[
The problem is that tcl lists are very delicate, while alot of coders/users think having one item per line automatically makes the string a list. The tcl interpreter will try it's best to parse the string as a list when using foreach, lindex, etc. but every now and then the string is too poorly formatted to make sense of.<br>In your case, you'll most likely get away with it, as I said in my previous post. But since this forum is alot about helping people code (better), I like to point out issues like these. If you get too comfortable with this "sloppy" (no offense) coding, it's very easy to start using them in cases  where this really becomes an issue.<br><br>All this said, if it works for you, of course feel free to do it any way you feel comfortabe. I just wan't you to be aware of posible issues.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Mon Mar 22, 2010 1:09 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[raider2k]]></name></author>
		<updated>2010-03-22T12:22:26-04:00</updated>

		<published>2010-03-22T12:22:26-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=92562#p92562</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=92562#p92562"/>
		<title type="html"><![CDATA[[SOLVED] catch errors, dont make eggy die]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=92562#p92562"><![CDATA[
yup, this is true, figured where scripts comes from when i copied and modified it to my needs ^^<br><br>yup, namespace global var, got that, just wasnt really sure ^^<br><br>im wondering a bit whats so wrong about my code, having escapable character in FILENAMES isnt going to happen at all, i NEVER used and never will use special chars in a filename, is there anything i need to be aware of or is it only characters which need to be escape in case of?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9589">raider2k</a> — Mon Mar 22, 2010 12:22 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2010-03-22T11:35:25-04:00</updated>

		<published>2010-03-22T11:35:25-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=92560#p92560</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=92560#p92560"/>
		<title type="html"><![CDATA[[SOLVED] catch errors, dont make eggy die]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=92560#p92560"><![CDATA[
First, your questions..<br><br>I placed my code in a proc I called "loadsafe", that takes one parameter (the list of scripts). So $scripts comes from the proc argument list..<br><br>Next, $::errorInfo:<br>This is a global variable (see the namespace operator ::), that contains details regarding the latest error that occured. Since I use a full namespace path when accessing the variable, I don't have to use the global command.<br><br>Regarding your code, I would recommend that you do not build your list of scripts that way. You'll get away with it most of the times, but if your filenames contains characters such as { or }, you might be up for a nasty surprise (plus it's really bad coding practise that we see all too often).<br><br>Regarding your issues with the list command and using backslash (\), did you place a newline immediately after the backslash? It is solely used to escape the newline, so there cannot be any spaces or other characters between the \ and the newline.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Mon Mar 22, 2010 11:35 am</p><hr />
]]></content>
	</entry>
	</feed>
