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

	<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>2005-05-25T08:46:45-04:00</updated>

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

		<entry>
		<author><name><![CDATA[De Kus]]></name></author>
		<updated>2005-05-25T08:46:45-04:00</updated>

		<published>2005-05-25T08:46:45-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=49797#p49797</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=49797#p49797"/>
		<title type="html"><![CDATA[question with some tcl + php code]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=49797#p49797"><![CDATA[
have you checked the content of $arg?<br>have you tried to put everything in one statement like:<br>fputs($fp, "line one here \nline two here \nline three here \nlast line \n\n");?<br><br>if you split the text over seperate fputs, you seem to get the proc called multiple times. because you kill the dcc all remaining lines are lost.<br>you can try something like that:<br><div class="codebox"><p>Code: </p><pre><code>proc vbincoming_admin1 {idx arg} {   if { $arg != "" &amp;&amp; $arg != "\n"} {      putserv "PRIVMSG #somechan :$arg"   } elseif { $arg == "\n" } {      killdcc $idx   }   return 0}</code></pre></div>if you know if it will be called with nothing or \n the last time, you further optimize it ^^<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2382">De Kus</a> — Wed May 25, 2005 8:46 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[blotter45]]></name></author>
		<updated>2005-05-24T17:32:44-04:00</updated>

		<published>2005-05-24T17:32:44-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=49784#p49784</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=49784#p49784"/>
		<title type="html"><![CDATA[question with some tcl + php code]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=49784#p49784"><![CDATA[
<blockquote class="uncited"><div>hmm, okay thats what I would do:<br>remove all those wannabe list braces {} from the fputs thing in the php scripts. mark each end of a line with unique character... like \n or using an other like ~ or ° depending, which wont cause other troubles ^-^.<br>then in your tcl scripts, use at the very begining:<br>set arg [split $arg \n]<br>or whatever character you chose. you finished the output with a double \n\n, so I dont know how you transfer the lines, i cant tell if it will cause troubles. in case you use \n and finish with \n\n the last element is emtpy, so you can remove it with:<br>set arg [lreplace $arg end end]<br><br>the rest of the code with the for loop and the lindex thing should now be nolonger any problem.<br><br>why using split instead of addcslashes? because split knows the best which chars has be backlashed and where {} have to be used!</div></blockquote>Thaks for your reply <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_wink.gif" width="15" height="15" alt=";)" title="Wink"><br><br>I tried your suggestions also, but all I end up with is just the first line of output being shown on irc.<br><br>ie, if I do this for the fputs in php:<br><div class="codebox"><p>Code: </p><pre><code>fputs($fp, "line one here \n");fputs($fp, "line two here \n");fputs($fp, "line three here \n");fputs($fp, "last line \n\n");</code></pre></div>then only the first line gets sent out to irc, not the rest <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_sad.gif" width="15" height="15" alt=":(" title="Sad"><br><br>(the \n\n is needed in the last fputs line, otherwise the script will just hang)<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=6025">blotter45</a> — Tue May 24, 2005 5:32 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[De Kus]]></name></author>
		<updated>2005-05-24T13:36:13-04:00</updated>

		<published>2005-05-24T13:36:13-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=49780#p49780</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=49780#p49780"/>
		<title type="html"><![CDATA[question with some tcl + php code]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=49780#p49780"><![CDATA[
hmm, okay thats what I would do:<br>remove all those wannabe list braces {} from the fputs thing in the php scripts. mark each end of a line with unique character... like \n or using an other like ~ or ° depending, which wont cause other troubles ^-^.<br>then in your tcl scripts, use at the very begining:<br>set arg [split $arg \n]<br>or whatever character you chose. you finished the output with a double \n\n, so I dont know how you transfer the lines, i cant tell if it will cause troubles. in case you use \n and finish with \n\n the last element is emtpy, so you can remove it with:<br>set arg [lreplace $arg end end]<br><br>the rest of the code with the for loop and the lindex thing should now be nolonger any problem.<br><br>why using split instead of addcslashes? because split knows the best which chars has be backlashed and where {} have to be used!<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2382">De Kus</a> — Tue May 24, 2005 1:36 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[blotter45]]></name></author>
		<updated>2005-05-24T12:46:47-04:00</updated>

		<published>2005-05-24T12:46:47-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=49775#p49775</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=49775#p49775"/>
		<title type="html"><![CDATA[question with some tcl + php code]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=49775#p49775"><![CDATA[
I think this is a step in the right direction tho:<br><br>fputs($fp, addcslashes("{ mystring }", "[]{}"));<br><br>when I use that method, all the the characters are properly shown on irc, but each word is shown on it's own line, that's the only problem.<br><br>and then I tried using addcslashes($varname,  "[]{}") on each different variable instead, and that shows the proper number of lines on irc, but each of the variables is empty.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=6025">blotter45</a> — Tue May 24, 2005 12:46 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[blotter45]]></name></author>
		<updated>2005-05-24T12:19:22-04:00</updated>

		<published>2005-05-24T12:19:22-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=49773#p49773</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=49773#p49773"/>
		<title type="html"><![CDATA[question with some tcl + php code]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=49773#p49773"><![CDATA[
<blockquote class="uncited"><div><blockquote class="uncited"><div>The tcl code is supposed to take each line from the php script, and output them on irc. But I get alot of tcl errors about "unmatched open brace in list", and only 1 line of text is shown on irc...[/code]<br><br>Try using the php function <a href="http://nl3.php.net/addcslashes" class="postlink">addcslashes</a>. I think the problem is not the tcl code but the php code. If you tried adding blackslashes in TCL then the problem should be resolved earlier.<div class="codebox"><p>Code: </p><pre><code>string addcslashes ( string str, string charlist )Returns a string with backslashes before characters that are listed in charlist parameter. It escapes \n, \r etc. in C-like style, characters with ASCII code lower than 32 and higher than 126 are converted to octal representation. Be careful if you choose to escape characters 0, a, b, f, n, r, t and v. They will be converted to \0, \a, \b, \f, \n, \r, \t and \v. In PHP \0 (NULL), \r (carriage return), \n (newline) and \t (tab) are predefined escape sequences, while in C all of these are predefined escape sequences. </code></pre></div><blockquote class="uncited"><div>also not sure if that is the correct fputs syntax for the php code.. </div></blockquote>its fine.<br><br><br>So before you send the string to the bot. so like:<div class="codebox"><p>Code: </p><pre><code>$fp = fsockopen ($botaddr, $botport, $errno, $errstr, 120); fputs($fp, addcslashes("{ mystring }", "[]{}")); </code></pre></div></div></blockquote>Thanks for the quick reply to this! And it seems using addcslashes does fix  the errors I was getting, and now all lines are shown rather than just one, but now there is a new problem, all of the php variables are empty when they get to the eggdrop <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_sad.gif" width="15" height="15" alt=":(" title="Sad"></div></blockquote><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=6025">blotter45</a> — Tue May 24, 2005 12:19 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[greenbear]]></name></author>
		<updated>2005-05-24T11:42:43-04:00</updated>

		<published>2005-05-24T11:42:43-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=49771#p49771</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=49771#p49771"/>
		<title type="html"><![CDATA[question with some tcl + php code]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=49771#p49771"><![CDATA[
convert $arg  to a list, using 'split',  before doing anything to it.<div class="codebox"><p>Code: </p><pre><code>set arg [lrange [split $arg] 0 end]</code></pre></div>and to convert it back to a string, you can use 'join'<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=24">greenbear</a> — Tue May 24, 2005 11:42 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Galadhrim]]></name></author>
		<updated>2005-05-24T11:46:09-04:00</updated>

		<published>2005-05-24T11:40:57-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=49770#p49770</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=49770#p49770"/>
		<title type="html"><![CDATA[question with some tcl + php code]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=49770#p49770"><![CDATA[
<blockquote class="uncited"><div>The tcl code is supposed to take each line from the php script, and output them on irc. But I get alot of tcl errors about "unmatched open brace in list", and only 1 line of text is shown on irc...[/code]<br><br>Try using the php function <a href="http://nl3.php.net/addcslashes" class="postlink">addcslashes</a>. I think the problem is not the tcl code but the php code. If you tried adding blackslashes in TCL then the problem should be resolved earlier.<div class="codebox"><p>Code: </p><pre><code>string addcslashes ( string str, string charlist )Returns a string with backslashes before characters that are listed in charlist parameter. It escapes \n, \r etc. in C-like style, characters with ASCII code lower than 32 and higher than 126 are converted to octal representation. Be careful if you choose to escape characters 0, a, b, f, n, r, t and v. They will be converted to \0, \a, \b, \f, \n, \r, \t and \v. In PHP \0 (NULL), \r (carriage return), \n (newline) and \t (tab) are predefined escape sequences, while in C all of these are predefined escape sequences. </code></pre></div><blockquote class="uncited"><div>also not sure if that is the correct fputs syntax for the php code.. </div></blockquote>its fine.<br><br><br>So before you send the string to the bot. so like:<div class="codebox"><p>Code: </p><pre><code>$fp = fsockopen ($botaddr, $botport, $errno, $errstr, 120); fputs($fp, addcslashes("{ mystring }", "[]{}")); </code></pre></div></div></blockquote><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2999">Galadhrim</a> — Tue May 24, 2005 11:40 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[blotter45]]></name></author>
		<updated>2005-05-24T11:07:35-04:00</updated>

		<published>2005-05-24T11:07:35-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=49768#p49768</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=49768#p49768"/>
		<title type="html"><![CDATA[question with some tcl + php code]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=49768#p49768"><![CDATA[
Hiya guys,<br><br>I've got an eggdrop tcl script, which takes output from a php script, and then announces it to a channel.<br><br>The php output is in the form:<br><br>line 1<br>line 2<br>line 3<br>etc<br><br>here are the lines of php code that send the output:<div class="codebox"><p>Code: </p><pre><code>$fp = fsockopen ($botaddr, $botport, $errno, $errstr, 120);fputs($fp,"{ \00314:::::::::::::::::::::::::::::::::: \0031[ \002\0037Test Title \002\0031] \00314:::::::::::::::::::::::::::::::::: } ");fputs($fp,"{ [\00314".$title."\0031] \00314::\0031 [\00314HEADING\0031] \00314::\0034 ".$lastthread." \00314::\0031 [\00314BY\0031] \00314::\0034 ".$lastposter." \00314@\0037 ".$tname." } ");fputs($fp,"{ \00314:::::::::::::::::::::::::::::::::: \0031[ \002\0037--------------------- \002\0031] \00314:::::::::::::::::::::::::::::::::: } \n\n");</code></pre></div>sometimes those php variables contain characters like []{}, so those have to be processed properly, without causing tcl errors.<br><br>here is the tcl script that processes the php output:<div class="codebox"><p>Code: </p><pre><code>listen 22625 script vbulletinaccept_admin1proc vbulletinaccept_admin1 {idx} {  putlog "ADMIN1: incoming connection on idx: $idx"  control $idx vbincoming_admin1}proc vbincoming_admin1 {idx arg} {  if {[join $arg] != ""} {    for { set i 0 } { $i &lt; [llength $arg] } { incr i } {      if {[lindex $arg $i] != ""} {        putserv "PRIVMSG #somechan :[lindex $arg $i]"      }    }  }  killdcc $idx}</code></pre></div>I've tried many different approaches in that tcl proc, but so far nothing works well to elimintate to tcl errors  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_sad.gif" width="15" height="15" alt=":(" title="Sad"><br><br>The tcl code is supposed to take each line from the php script, and output them on irc. But I get alot of tcl errors about "unmatched open brace in list", and only 1 line of text is shown on irc, also not sure if that is the correct fputs syntax for the php code.. <br><br>Is there something I'm missing on the php side of things, or is there a way to prevent any errors from the tcl side? I have also tried using regsub to add backslashes to characters like {}[] in the tcl proc, but no luck their either <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_sad.gif" width="15" height="15" alt=":(" title="Sad"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=6025">blotter45</a> — Tue May 24, 2005 11:07 am</p><hr />
]]></content>
	</entry>
	</feed>
