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

	<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>2009-01-23T09:46:04-04:00</updated>

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

		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2009-01-23T09:46:04-04:00</updated>

		<published>2009-01-23T09:46:04-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=87087#p87087</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=87087#p87087"/>
		<title type="html"><![CDATA[Getting a bash script to communicate with an eggdrop]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=87087#p87087"><![CDATA[
Sorry for that, two of those nasty typos that just slip through no matter how many times you re-read your post before submitting. Updated previous post to correct both issues.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Fri Jan 23, 2009 9:46 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[karrde]]></name></author>
		<updated>2009-01-23T04:06:23-04:00</updated>

		<published>2009-01-23T04:06:23-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=87082#p87082</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=87082#p87082"/>
		<title type="html"><![CDATA[Getting a bash script to communicate with an eggdrop]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=87082#p87082"><![CDATA[
Perfect! Thanks to your code, I'm a lot closer than I was before. Thanks for your help!<br><br>I did notice though that I can't actually do "echo write #mychan blah" because echo interprets the # as the start of a remark <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"> Oh, and I had to change<br><div class="codebox"><p>Code: </p><pre><code>listen 12345 IncomingConnection</code></pre></div>to<br><div class="codebox"><p>Code: </p><pre><code>listen 12345 script IncomingConnection</code></pre></div>because otherwise it'd complain about an invalid type.<br><br>But anyway, thanks again!<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10443">karrde</a> — Fri Jan 23, 2009 4:06 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2009-01-23T09:39:20-04:00</updated>

		<published>2009-01-22T15:24:53-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=87070#p87070</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=87070#p87070"/>
		<title type="html"><![CDATA[Getting a bash script to communicate with an eggdrop]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=87070#p87070"><![CDATA[
One thing I did forget, is that opening a pipe in RDONLY-mode will block until another process opens the pipe in RWONLY-mode. With normal tcl-scripting this would probably not be such a big issue, as this would probably be some server-like application. With eggdrops however, this would prevent your eggdrop from performing it's normal tasks.<br><br>One option still would be using tcp-sockets, and use nc (if available). This however has the downside that anyone who knows the listening-port could connect there and send arbitrary data. You would thus have to implement some kind of safety-mechanism.<br>To achieve something like this however, you'd do something like this:<div class="codebox"><p>Code: </p><pre><code>listen 12345 script IncomingConnectionproc IncomingConnection {idx} { #We've got a new incoming connection, hand it over to our "handler" control $idx IncomingTransmission}proc IncomingTransmission {idx text} { #Did we recieve a new line, or did the remote end close the connection? if {$text != ""} {  #Slit the text into a list and retrieve the command..  set data [split $text]  set command [lindex $data 0]  #.. and see what we're supposed to do.  #Hint: this would be a nice place to add a command for authentication...  switch $command {   write {    #Use list-element 1 as channel, and the rest as the message to be sent    #Considder adding a check whether the connection has authenticated or not yet.    #Atleast we do check that it's a valid channel..    if {[validchan [set chan [lindex $data 1]]]} {     puthelp "PRIVMSG $chan :[join [lrange $data 2 end]]"    }   }  } } else {  #remote connection closed, do some cleanup here if needed  #Hint: here you would un-authenticate the idx (connection identifier)  #For now tho, we'll just do a putlog for fun  putlog "Remote connection $idx dropped" }}</code></pre></div>This is a very, very crude example, and does no authentication whatsoever. You should thus extend this with some kind of protection/authentication/etc to prevent sending arbitrary messages to your channels.<br><br>To send a message from your bash-script, do something like this:<div class="codebox"><p>Code: </p><pre><code>#simple case, where we have no authentication or such:echo "write #mychan Cleaning $dir" | nc localhost 12345#Lets imagine we've implemented an authenticate-command that has to be issued before write...#Send multiple commands like this:nc localhost 12345 &lt;&lt;EOFauthenticate mysecretpasswordwrite #mychan Clearing $dirEOF</code></pre></div><strong class="text-strong">edit:</strong> fixing minor typos<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Thu Jan 22, 2009 3:24 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[karrde]]></name></author>
		<updated>2009-01-21T23:18:39-04:00</updated>

		<published>2009-01-21T23:18:39-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=87064#p87064</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=87064#p87064"/>
		<title type="html"><![CDATA[Getting a bash script to communicate with an eggdrop]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=87064#p87064"><![CDATA[
<blockquote class="uncited"><div>I guess you could consider using named pipes to communicate with your eggdrop that way.<br><br>In that case, you'd have to set up a "listener" within your eggdrop (open, fconfigure, fileevent, gets, eof) to listen at the pipe, and take appropriate actions upon incoming transmissions.<br>In order to transmit to your eggdrop, it would be a mere matter of<div class="codebox"><p>Code: </p><pre><code>echo write #chan Clearing $dir &gt;&gt; /path/to/the/pipe</code></pre></div>Also see the manpage for mkfifo for further information on named pipes.</div></blockquote>Could you possibly describe how to set up the listener within eggdrop in a bit more detail? I'm new to the whole eggdrop thing. I'm trying to get a script to notify a channel when something external happens, if there's a better way to handle this then please let me know. Much appreciated. <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=10443">karrde</a> — Wed Jan 21, 2009 11:18 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2009-01-10T11:45:30-04:00</updated>

		<published>2009-01-10T11:45:30-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=86837#p86837</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=86837#p86837"/>
		<title type="html"><![CDATA[Getting a bash script to communicate with an eggdrop]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=86837#p86837"><![CDATA[
Rather than using return, I'd make use of the fact that it's just an anonymous pipe... Hence anything sent to stdout would be returned by <strong class="text-strong">exec</strong>.<br><br>Still, this leaves the issue of being able to do this directly from the shell environment. I guess you could telnet into the eggdrop from the shell and do it that way...<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Sat Jan 10, 2009 11:45 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[incith]]></name></author>
		<updated>2009-01-10T10:52:49-04:00</updated>

		<published>2009-01-10T10:52:49-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=86829#p86829</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=86829#p86829"/>
		<title type="html"><![CDATA[Getting a bash script to communicate with an eggdrop]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=86829#p86829"><![CDATA[
Well, I didn't test that and had posted it roughly 0.34 seconds after waking up, but...<div class="codebox"><p>Code: </p><pre><code>% set foo [exec lalala]couldn't execute "lalala": no such file or directory% set foocan't read "foo": no such variable</code></pre></div>Nevermind I think I know what you are getting at.. as long as it execs something, it should return 0 or 1, ya.  And so you'd want to use if {$foo == x}.. or just if {[exec] == x}<br><br>I guess my method won't work anyway without some modification to make it a function..<div class="codebox"><p>Code: </p><pre><code>% set foo [exec ./test.sh]./test.sh: line 2: return: can only `return' from a function or sourced script</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=6130">incith</a> — Sat Jan 10, 2009 10:52 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2009-01-10T09:50:46-04:00</updated>

		<published>2009-01-10T09:50:46-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=86827#p86827</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=86827#p86827"/>
		<title type="html"><![CDATA[Getting a bash script to communicate with an eggdrop]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=86827#p86827"><![CDATA[
@incith: Wouldn't <em class="text-italics">foo</em> always exist in that example?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Sat Jan 10, 2009 9:50 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[incith]]></name></author>
		<updated>2009-01-10T09:48:51-04:00</updated>

		<published>2009-01-10T09:48:51-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=86826#p86826</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=86826#p86826"/>
		<title type="html"><![CDATA[Getting a bash script to communicate with an eggdrop]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=86826#p86826"><![CDATA[
I was thinking just returning certain codes from the shell script.  If you return 1... well.  Let's put it this way:<br><div class="codebox"><p>Code: </p><pre><code>#!/bin/shfind *.txt &gt;&gt; fils.lst rm -f *.txt dir=`pwd`return 1</code></pre></div><div class="codebox"><p>Code: </p><pre><code>set foo [exec maihappyness.sh] .. if {[info exists foo]} { putserv hi2u }}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=6130">incith</a> — Sat Jan 10, 2009 9:48 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2009-01-10T08:41:11-04:00</updated>

		<published>2009-01-10T08:41:11-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=86825#p86825</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=86825#p86825"/>
		<title type="html"><![CDATA[Getting a bash script to communicate with an eggdrop]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=86825#p86825"><![CDATA[
I guess you could consider using named pipes to communicate with your eggdrop that way.<br><br>In that case, you'd have to set up a "listener" within your eggdrop (open, fconfigure, fileevent, gets, eof) to listen at the pipe, and take appropriate actions upon incoming transmissions.<br>In order to transmit to your eggdrop, it would be a mere matter of<div class="codebox"><p>Code: </p><pre><code>echo write #chan Clearing $dir &gt;&gt; /path/to/the/pipe</code></pre></div>Also see the manpage for mkfifo for further information on named pipes.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Sat Jan 10, 2009 8:41 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[onesikgypo]]></name></author>
		<updated>2009-01-10T02:51:55-04:00</updated>

		<published>2009-01-10T02:51:55-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=86822#p86822</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=86822#p86822"/>
		<title type="html"><![CDATA[Getting a bash script to communicate with an eggdrop]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=86822#p86822"><![CDATA[
could you give a bit more detail on how to do this/how this works - ie. if i had a bash script with<br><br>#!/bin/bash<br>find *.txt &gt;&gt; fils.lst<br>rm -f *.txt<br>dir=`pwd`<br>;;MSG HERE- Msg #chan Cleaning $dir;;<br><br>as an example, how would i go about it - and if eggdrop needs to execute the script, im guessing then if executing via ssh then no msges will occur - if this is the case, is there a way i can write an ssh script, which will force the eggdrop to execute the said script (the point of which is that i can continue using ssh?)<br><br>Thanks.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9991">onesikgypo</a> — Sat Jan 10, 2009 2:51 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[incith]]></name></author>
		<updated>2009-01-10T02:40:00-04:00</updated>

		<published>2009-01-10T02:40:00-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=86820#p86820</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=86820#p86820"/>
		<title type="html"><![CDATA[Getting a bash script to communicate with an eggdrop]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=86820#p86820"><![CDATA[
You will need eggdrop to exec the script.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=6130">incith</a> — Sat Jan 10, 2009 2:40 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[onesikgypo]]></name></author>
		<updated>2009-01-10T02:31:19-04:00</updated>

		<published>2009-01-10T02:31:19-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=86819#p86819</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=86819#p86819"/>
		<title type="html"><![CDATA[Getting a bash script to communicate with an eggdrop]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=86819#p86819"><![CDATA[
Hi,<br><br>I have a bash script already made, however a new addition id like to make, is that whent he script is executed, my eggdrop msg's a channel with such details. I have already installed and setup my eggdrop, however i have no idea how i can get bash to talk with the eggdrop in order to perform what i require.<br><br>Any assistance will be greatly appreciated.<br><br>Thankyou.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9991">onesikgypo</a> — Sat Jan 10, 2009 2:31 am</p><hr />
]]></content>
	</entry>
	</feed>
