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

	<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>2013-01-17T04:20:52-04:00</updated>

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

		<entry>
		<author><name><![CDATA[EzMe]]></name></author>
		<updated>2013-01-17T04:20:52-04:00</updated>

		<published>2013-01-17T04:20:52-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=100620#p100620</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=100620#p100620"/>
		<title type="html"><![CDATA[[SOLVED] Cannot run bgexec in an if statement]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=100620#p100620"><![CDATA[
Hahaha cheers m8 <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"> It seems it is working fine all and, as this is my first script, I'm pretty satisfied with this <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=12176">EzMe</a> — Thu Jan 17, 2013 4:20 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2013-01-15T10:01:46-04:00</updated>

		<published>2013-01-15T10:01:46-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=100614#p100614</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=100614#p100614"/>
		<title type="html"><![CDATA[[SOLVED] Cannot run bgexec in an if statement]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=100614#p100614"><![CDATA[
Your welcome. Anyway, you should rethink your <em class="text-italics">pub_go</em> proc code as it's a bit messy, I tried to follow your logic but failed miserably (tiered I guess).<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Tue Jan 15, 2013 10:01 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[EzMe]]></name></author>
		<updated>2013-01-15T09:08:18-04:00</updated>

		<published>2013-01-15T09:08:18-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=100613#p100613</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=100613#p100613"/>
		<title type="html"><![CDATA[[SOLVED] Cannot run bgexec in an if statement]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=100613#p100613"><![CDATA[
Thanks caesar! That did the trick! You just made my day <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=12176">EzMe</a> — Tue Jan 15, 2013 9:08 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2013-01-15T08:37:29-04:00</updated>

		<published>2013-01-15T08:37:29-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=100612#p100612</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=100612#p100612"/>
		<title type="html"><![CDATA[[SOLVED] Cannot run bgexec in an if statement]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=100612#p100612"><![CDATA[
Have you tried moving the <em class="text-italics">callback</em> proc outside the pub_go proc?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Tue Jan 15, 2013 8:37 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[EzMe]]></name></author>
		<updated>2013-01-15T09:08:37-04:00</updated>

		<published>2013-01-15T06:18:25-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=100611#p100611</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=100611#p100611"/>
		<title type="html"><![CDATA[[SOLVED] Cannot run bgexec in an if statement]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=100611#p100611"><![CDATA[
Hi all,<br><br>I've been using eggdrop for some years now and decided to make my own tcl script now. What I'm trying to do is start an external bash script, wait for it's output and echo a line containing certain info into the chan. I've got this working and the code looks like this:<br><div class="codebox"><p>Code: </p><pre><code>bind pub - !start start_msgproc start_msg {nick uhost hand chan arg} {bgexec "./go.sh" callback 5}proc callback {input} { foreach line [split $input "\n"] {      if  [string match "*hex:*" [string tolower $line]] {      puthelp "privmsg #mychan : Results : $line"           }      }}</code></pre></div>As you can see I'm using another tcl called bgexec.tcl in order to make this work.<br><br>Now, sinds this is working I want to add an syntax to this program in go.sh true IRC. This syntaxt needs to meet a couple of requirements in order to be valid. My code looks like this:<br><div class="codebox"><p>Code: </p><pre><code>bind pub * !start pub_goproc pub_go { nick host handle chan text} {set arg $text        if {![file exists syntax.txt]} {set a [open syntax.txt w]; close $a}        set syntax [open syntax.txt r+]                if {$arg == "" &amp;&amp; [read $syntax] != ""} {                putmsg $chan "\002\0034::\003 Program started...\002"                puts $syntax $arg                close $syntax# ------------------------------------------------------------------# Code downhere does not start                bgexec "./go.sh" callback 5                proc callback {input} {                foreach line [split $input "\n"] {                      if  [string match "*hex:*" [string tolower $line]] {                      puthelp "privmsg #mychan : Results : $line"                           }                     }                 }# Till here# ------------------------------------------------------------------        } elseif {$arg == "" &amp;&amp; [read $syntax ] == ""} {                close $syntax                 putmsg $chan "\002\0034::\003 Add a syntax to program first\002"        } elseif {[lsearch -inline $arg *:*:*:*:::] == $arg} {                close $syntax                 putmsg $chan "\002\0034::\003 Program started with syntax: $arg\002"                if {[file exists syntax.txt]} {file delete -force syntax.txt}                set b [open syntax.txt a]                puts $b $arg                close $b# ------------------------------------------------------------------# Code downhere does not start                bgexec "./go.sh" callback 5                proc callback {input} {                foreach line [split $input "\n"] {                      if  [string match "*hex:*" [string tolower $line]] {                      puthelp "privmsg #mychan : Results : $line"                           }                      }                }# Till here------------------------------------------------------------------          else {                close $syntax                putmsg $chan "\002\0034::\003 Invalid syntax\002"        }   }}</code></pre></div>So my question is, how can I start bgexec after it meets all the requirements? Is there a way to proc it? <br><br>Thanks in advanced!<br><br>Grtz EzMe <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><br><br><br>btw, bgexec.tcl looks like this:<br><div class="codebox"><p>Code: </p><pre><code>#### bgexec.tcl v1.1 - by strikelight ([sL] @ EFNet) (09/05/02)## For eggdrop1.1.5-eggdrop1.6.x## Contact:# - E-Mail: strikelight@tclscript.com# - WWW   : http://www.TCLScript.com# - IRC   : #Scripting @ EFNet##### Description:## This script is for other scripters to use as a replacement# for the "exec" command so that they may execute commands to# the system in the background. (non-blocking mode)##### History:## (09/05/02):v1.1 - Fixed callback bug to allow calling of a callback#                   procedure with a list of parameters#                   (ie. bgexec &lt;command&gt; [list &lt;command_callback&gt; &lt;arg1&gt; &lt;arg2&gt;])## (05/27/02):v1.0 - Initial Release##### Usage:## example #1 (for eggdrop1.4.x-eggdrop1.6.x users):##   proc callback {input} {#     foreach line [split $input "\n"] {#       putserv "PRIVMSG #test :$line"#     }#   }#   bgexec "command here" callback## NOTE: This example (#1) will also work for eggdrop1.1.5-1.3.x users,#       however, it will only be non-blocking for a default of 5 seconds#       (since egg1.1.5-egg1.3.x do not use Tcl_DoOneEvent, a vwait will#        be executed after 5 seconds, thus blocking processing until#        the execution of the command is done). See example #2 for changing#       the default waiting time.### example #2 (for eggdrop1.1.5-eggdrop1.3.x users):##   proc callback {input} {#     foreach line [split $input "\n"] {#       putserv "PRIVMSG #test :$line"#     }#   }#   bgexec "command here" callback 20 ;# this will wait 20 seconds before#                                      # checking for the results of the#                                      # command (and effectively, returning#                                      # to blocking mode). Change 20 to#                                      # whatever you feel comfortable with.#### example #3 (error checking):##   proc callback {input} {#     ...#   }#   if {[catch {bgexec "command here" callback} err]} {#     putlog "Error executing command: $err"#   }### example #4 (multi-parameters):##   proc callback {arg1 arg2 input} {#     ...#   }#   if {[catch {bgexec "command here" [list callback $arg1 $arg2]} err]} {#     putlog "Error executing command: $err"#   }###set bgexec(version) "1.1"proc bgexec_process {fileid callback} {  global buffer bgexectest  if {[eof $fileid]} {    catch {close $fileid}    set buffer($fileid) [lrange $buffer($fileid) 0 [expr [llength $buffer($fileid)] - 2]]    set buffer($fileid) [join $buffer($fileid) "\n"]    catch {eval $callback {$buffer($fileid)}}    catch {unset buffer($fileid)}    set bgexectest($fileid) 1    return  }  if {[catch {gets $fileid dataline} err]} {    catch {close $fileid}    set buffer($fileid) "error: $err"    catch {eval $callback {$buffer($fileid)}}    catch {unset buffer($fileid)}    set bgexectest($fileid) 1  }  lappend buffer($fileid) $dataline}proc bgexec {{command ""} {callback ""} {flush 5}} {  global buffer bgeggversion  if {($command == "") || ($callback == "")} {    return -code error "wrong # args: should be \"bgexec command callback ?wait?\""  }  if {[catch {info body [lindex [split $callback] 0]} err]} {    return -code error "$err"  }  if {[catch {set infile [open "|$command" "r+"]} err]} {    return -code error "$err"  }  set buffer($infile) ""  fileevent $infile readable [list bgexec_process $infile $callback]  fconfigure $infile -blocking 0  if {[info exists bgeggversion] &amp;&amp; ($bgeggversion &lt; 1040000)} {    utimer $flush "bgexec_flush $infile"  }  return $infile}if {[info exists version]} {  set bgeggversion [string trimleft [lindex $version 1] 0]  if {$bgeggversion &lt; 1040000} {    proc bgexec_flush {fileid} {      global bgexectest      vwait bgexectest($fileid)      catch {unset bgexectest($fileid)}    }  }}putlog "bgexec.tcl v$bgexec(version) by strikelight now loaded."</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12176">EzMe</a> — Tue Jan 15, 2013 6:18 am</p><hr />
]]></content>
	</entry>
	</feed>
