| View previous topic :: View next topic |
| Author |
Message |
tessa1 Halfop
Joined: 18 Apr 2005 Posts: 49 Location: Germany
|
Posted: Fri Mar 24, 2006 6:09 pm Post subject: Need a script to start some applications on my shell |
|
|
Hi,
I need a script that allows to start some applications on my shell, only in channel #opers, with one public command.
The commands for the shell are ./services ./neostats and ./eggdrop
I can't use exec, because the bot is freezing.
Best regards |
|
| Back to top |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Tue Mar 28, 2006 1:23 am Post subject: Re: Need a script to start some applications on my shell |
|
|
| tessa1 wrote: |
I can't use exec, because the bot is freezing.
Best regards |
then use [open "|application"] for non-blocking I/O
search the forums for "tail -f" example on how to do that _________________ connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use [code] tag when posting logs, code |
|
| Back to top |
|
 |
tessa1 Halfop
Joined: 18 Apr 2005 Posts: 49 Location: Germany
|
Posted: Tue Mar 28, 2006 3:32 pm Post subject: Re: Need a script to start some applications on my shell |
|
|
| demond wrote: | | tessa1 wrote: |
I can't use exec, because the bot is freezing.
Best regards |
then use [open "|application"] for non-blocking I/O
search the forums for "tail -f" example on how to do that |
Yes...i heard from [open "|tail -f $filepath"]
...but i can't script this request by myself.
Thats the reason, why I am in Script Request and not in Scripting Help
Best regards |
|
| Back to top |
|
 |
tessa1 Halfop
Joined: 18 Apr 2005 Posts: 49 Location: Germany
|
Posted: Wed Mar 29, 2006 10:38 am Post subject: |
|
|
Ok.. i try to script this:
| Code: |
bind pub - !sne sne:start
proc sne:start {nick uhost hand chan arg} {
if {([file readable /home/eggdrop/eggdrop]) && ([file readable /home/ircd/services/services]) && ([file readable /home/NeoStats/neostats])} {
set ca [open "|tail -f /home/eggdrop/eggdrop"]
set cb [open "|tail -f /home/ircd/services/services"]
set cc [open "|tail -f /home/NeoStats/neostats"]
fconfigure $ca -blocking 0
fconfigure $cb -blocking 0
fconfigure $cc -blocking 0
fileevent $ca readable {putserv "privmsg $nick :[read $ca]"}
fileevent $cb readable {putserv "privmsg $nick :[read $cb]"}
fileevent $cb readable {putserv "privmsg $nick :[read $cc]"}
close $ca; close $cb; close $cc
}
return 1
} |
But don't works!
Can anyone fix that PLEASE?
Best regards |
|
| Back to top |
|
 |
De Kus Revered One

Joined: 15 Dec 2002 Posts: 1361 Location: Germany
|
Posted: Wed Mar 29, 2006 1:22 pm Post subject: |
|
|
because you get the TCL error '$ca, no such variable'. look at your {} braces and think about them. _________________ De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens... |
|
| Back to top |
|
 |
tessa1 Halfop
Joined: 18 Apr 2005 Posts: 49 Location: Germany
|
Posted: Wed Mar 29, 2006 2:08 pm Post subject: |
|
|
| I don't know, what is wrong with the braces. |
|
| Back to top |
|
 |
De Kus Revered One

Joined: 15 Dec 2002 Posts: 1361 Location: Germany
|
Posted: Wed Mar 29, 2006 7:58 pm Post subject: |
|
|
Sorry, I didn't notice its not called within an proc. But I see another problem. The file sockets are closed before its read from (because of asyncronous connection and fileevent). Try to move the close statements after the putservs with a ; seperatred, so it looks like:
fileevent $ca readable [list putserv "privmsg $nick :\[read $ca\]"; close $ca] _________________ De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens... |
|
| Back to top |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Wed Mar 29, 2006 11:12 pm Post subject: |
|
|
...not to mention you don't need tail -f here - learn the basics of Linux command line first and only then try to script it _________________ connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use [code] tag when posting logs, code |
|
| Back to top |
|
 |
tessa1 Halfop
Joined: 18 Apr 2005 Posts: 49 Location: Germany
|
Posted: Thu Mar 30, 2006 10:32 am Post subject: Re: Need a script to start some applications on my shell |
|
|
| demond wrote: | | tessa1 wrote: |
I can't use exec, because the bot is freezing.
Best regards |
then use [open "|application"] for non-blocking I/O
search the forums for "tail -f" example on how to do that |
hmmm.... |
|
| Back to top |
|
 |
tessa1 Halfop
Joined: 18 Apr 2005 Posts: 49 Location: Germany
|
Posted: Thu Mar 30, 2006 10:46 am Post subject: |
|
|
I hope, this is right now
| Code: |
bind pub - !sne sne:start
proc sne:start {nick uhost hand chan arg} {
if {([file readable /home/eggdrop/eggdrop]) && ([file readable /home/ircd/services/services]) && ([file readable /home/NeoStats/neostats])} {
set ca [open "|/home/eggdrop/eggdrop"]
set cb [open "|/home/ircd/services/services"]
set cc [open "|/home/NeoStats/neostats"]
fconfigure $ca -blocking 0
fconfigure $cb -blocking 0
fconfigure $cc -blocking 0
fileevent $ca readable [list putserv "privmsg $nick :\[read $ca\]"; close $ca]
fileevent $cb readable [list putserv "privmsg $nick :\[read $cb\]"; close $cb]
fileevent $cc readable [list putserv "privmsg $nick :\[read $cc\]"; close $cc]
}
return 1
}
|
|
|
| Back to top |
|
 |
tessa1 Halfop
Joined: 18 Apr 2005 Posts: 49 Location: Germany
|
Posted: Thu Mar 30, 2006 1:07 pm Post subject: |
|
|
Don't work...
| Quote: | | Tcl error [sne:start]: can not find channel named "file10" |
ps x
| Quote: |
29458 ? Z 0:00 [eggdrop] <defunct>
29459 ? Z 0:00 [services] <defunct>
29460 ? Z 0:00 [neostats] <defunct> |
|
|
| Back to top |
|
 |
De Kus Revered One

Joined: 15 Dec 2002 Posts: 1361 Location: Germany
|
Posted: Thu Mar 30, 2006 9:51 pm Post subject: |
|
|
I am sure demond wanted you to read about seek which can be used to set the reading pointer at x bytes before eof. You cannot open text files with |. You can only open files with | which are marked as executable and can be run by bash as either script or application, otherwise you will get an error.
PS: i wouldnt use async IO on local files when reading less than ~1mb. _________________ De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens... |
|
| Back to top |
|
 |
|