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

	<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>2007-09-10T14:48:38-04:00</updated>

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

		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2007-09-10T14:48:38-04:00</updated>

		<published>2007-09-10T14:48:38-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=75849#p75849</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=75849#p75849"/>
		<title type="html"><![CDATA[External Program (mysql) Partyline Interface]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=75849#p75849"><![CDATA[
Or my head is messed up enough already (with a blocked nose and nice cold)<br>Would have to agree you've got the arguments right..<br><br>As for bgerror, I would just dump the info to the logging facility. Usually should'nt be anything interresting there for your average user, but rather developer and/or botadmin.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Mon Sep 10, 2007 2:48 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[user]]></name></author>
		<updated>2007-09-10T13:56:55-04:00</updated>

		<published>2007-09-10T13:56:55-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=75848#p75848</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=75848#p75848"/>
		<title type="html"><![CDATA[External Program (mysql) Partyline Interface]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=75848#p75848"><![CDATA[
<blockquote class="uncited"><div>mysql_in expects three arguments, yet while setting up the fileevent controller, you only define two. Also, the 'control' event is set up to pass one additional argument, which is not supported by mysql_out. Sort those out, and my guess is it'll work like a charm.</div></blockquote>The fileevent invokes mysql_out, and dcc input is handled by mysql_in, so it seems about right to me (but I'm pretty tired right now, so I might have missed/messed up something <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_razz.gif" width="15" height="15" alt=":P" title="Razz">) Having a bgerror proc is a good idea though, but getting the output to the user under 'control' is a bit messy...<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2878">user</a> — Mon Sep 10, 2007 1:56 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2007-09-10T10:52:06-04:00</updated>

		<published>2007-09-10T10:52:06-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=75845#p75845</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=75845#p75845"/>
		<title type="html"><![CDATA[External Program (mysql) Partyline Interface]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=75845#p75845"><![CDATA[
There's a couple of argument mismatches in the script.<br><br>mysql_in expects three arguments, yet while setting up the fileevent controller, you only define two. Also, the 'control' event is set up to pass one additional argument, which is not supported by mysql_out. Sort those out, and my guess is it'll work like a charm.<br><br>Edit:<br><em class="text-italics">I would also recommend implementing the </em>bgerror<em class="text-italics"> error reporting mechanism when trying to debug scripts using tcl's native event-handler, as errors here tend to go unnoticed due to the very nature of the handler.</em><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Mon Sep 10, 2007 10:52 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[user]]></name></author>
		<updated>2007-09-10T09:06:51-04:00</updated>

		<published>2007-09-10T09:06:51-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=75840#p75840</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=75840#p75840"/>
		<title type="html"><![CDATA[External Program (mysql) Partyline Interface]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=75840#p75840"><![CDATA[
I added some error handling...try this: <div class="codebox"><p>Code: </p><pre><code>bind dcc n mysql mysql_initproc mysql_init {h i a} {*dcc:tcl $h $i [list mysql_init2 $h $i $a]}proc mysql_init2 {h i a} {if {[catch {open "|mysql -u user --password=pwd db" r+} dbi]} {return "Open error: $dbi"} {fconfigure $dbi -blocking 0 -buffering linefileevent $dbi readable [list mysql_out $dbi $i]control $i [list mysql_in $dbi]return "Type 'exit' to return to the real world."}}proc mysql_in {dbi i a} { if {$a=="exit"||$a==""} { close $dbireturn 1} elseif {[catch {puts $dbi $a; flush $dbi} err]} {putdcc $i "Write error: $err"close $dbireturn 1} {return 0}}proc mysql_out {dbi i} {if {[eof $dbi]} {close $dbiputdcc $i "EOF."control $i {}} elseif {[catch {while {![fblocked $dbi]&amp;&amp;[gets $dbi line]&gt;-1} {putdcc $i $line}} err]} {close $dbiputdcc $i "Read error: $err"control $i {}}}</code></pre></div>(not tested)<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2878">user</a> — Mon Sep 10, 2007 9:06 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[MikeM]]></name></author>
		<updated>2007-09-10T03:07:16-04:00</updated>

		<published>2007-09-10T03:07:16-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=75835#p75835</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=75835#p75835"/>
		<title type="html"><![CDATA[Re: External Program (mysql) Partyline Interface]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=75835#p75835"><![CDATA[
Doesnt seem to have any effect.<br><br>If I put a debug line on the second line of the proc (before first if statement), it enters an endless loop, but never meets the other requirements.<br><br>It's as though nothing is coming back from mysql-client (either because the code is wrong, or mysql-client never receives anything in the first place).<br><br>[gets $dbi] seems to always return ""<br><br>Ideas?  Can this even be done?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9299">MikeM</a> — Mon Sep 10, 2007 3:07 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[user]]></name></author>
		<updated>2007-09-10T02:36:38-04:00</updated>

		<published>2007-09-10T02:36:38-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=75834#p75834</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=75834#p75834"/>
		<title type="html"><![CDATA[Re: External Program (mysql) Partyline Interface]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=75834#p75834"><![CDATA[
<blockquote class="uncited"><div><div class="codebox"><p>Code: </p><pre><code>proc gotline {dbi} { if {![eof $dbi]} {  if {[gets $dbi] != ""} {    putserv "privmsg empus :(debug) [gets $dbi]"    #putdcc $i "mysql: [gets $dbi]"  } }}</code></pre></div></div></blockquote>Try something like this inside the first 'if': <div class="codebox"><p>Code: </p><pre><code>while {[gets $dbi line]&gt;-1} {putserv "PRIVMSG empus :(debug) $line"}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2878">user</a> — Mon Sep 10, 2007 2:36 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[MikeM]]></name></author>
		<updated>2007-09-09T22:20:25-04:00</updated>

		<published>2007-09-09T22:20:25-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=75833#p75833</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=75833#p75833"/>
		<title type="html"><![CDATA[External Program (mysql) Partyline Interface]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=75833#p75833"><![CDATA[
Hi,<br><br>I'm trying to provide a partyline interface to mysql-client, for convenience, and a bit of interest as to the method.<br><br>Basically I want to pipe the i/o to and from the external program (mysql), to display results in the dcc partyline.<br><br>Not to be confused, I already use a mysql module for code -  I want to emulate the entire mysql client by executing it externally.<br><br>After a tip from someone, and looking at user's code on another forum topic, I came up with this:<br><div class="codebox"><p>Code: </p><pre><code>bind dcc n mysql mysql_1proc mysql_1 {h i a} {     # hack to honor the "must-be-owner" setting:      *dcc:tcl $h $i [list mysql_2 $h $i $a]}proc mysql_2 {h i a} {      global dbi      set dbi [open "|mysql -u user --password=pwd db" r+]      fconfigure $dbi -blocking 0 -buffering line      fileevent $dbi readable [list gotline $dbi]      control $i [list mysql_3 $h]      return "Type 'exit' to return to the real world."}proc mysql_3 {h i a} {      global dbi         if {$a=="exit"} {            unset a            close $dbi            return 1         } {            puts $dbi $a            flush $dbi            putserv "privmsg empus :(debug) puts $dbi $a"           set a ""         }         append a \n      return 0}# EDIT: Added this proc for stupid irc clients that# are incapable of displaying the tab character (\x09)# Remove it if you don't need it.proc putdcc {i a} {::putdcc $i [string map {\t "    "} $a]}proc gotline {dbi} { if {![eof $dbi]} {  if {[gets $dbi] != ""} {    putserv "privmsg empus :(debug) [gets $dbi]"    #putdcc $i "mysql: [gets $dbi]"  } }}putlog "\[@\] MySQL Interface Loaded."</code></pre></div>However, it appears as though gotline is not being triggered - for whatever reason.  I get nothing back, which begs the question - is mysql receiving anything in the first place?<br><br>Something is wrong here, but I'm not quite sure what... any help would be much appreciated.<br><br>Cheers,<br><br>-Mike<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9299">MikeM</a> — Sun Sep 09, 2007 10:20 pm</p><hr />
]]></content>
	</entry>
	</feed>
