This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Need a script to start some applications on my shell

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
t
tessa1
Halfop
Posts: 49
Joined: Mon Apr 18, 2005 12:51 pm
Location: Germany

Need a script to start some applications on my shell

Post by tessa1 »

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
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Re: Need a script to start some applications on my shell

Post by demond »

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: Select all

 tag when posting logs, code
t
tessa1
Halfop
Posts: 49
Joined: Mon Apr 18, 2005 12:51 pm
Location: Germany

Re: Need a script to start some applications on my shell

Post by tessa1 »

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
t
tessa1
Halfop
Posts: 49
Joined: Mon Apr 18, 2005 12:51 pm
Location: Germany

Post by tessa1 »

Ok.. i try to script this:

Code: Select all

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
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

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...
t
tessa1
Halfop
Posts: 49
Joined: Mon Apr 18, 2005 12:51 pm
Location: Germany

Post by tessa1 »

I don't know, what is wrong with the braces.
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

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...
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

...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: Select all

 tag when posting logs, code
t
tessa1
Halfop
Posts: 49
Joined: Mon Apr 18, 2005 12:51 pm
Location: Germany

Re: Need a script to start some applications on my shell

Post by tessa1 »

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....
t
tessa1
Halfop
Posts: 49
Joined: Mon Apr 18, 2005 12:51 pm
Location: Germany

Post by tessa1 »

I hope, this is right now :)

Code: Select all

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
}
t
tessa1
Halfop
Posts: 49
Joined: Mon Apr 18, 2005 12:51 pm
Location: Germany

Post by tessa1 »

Don't work...
Tcl error [sne:start]: can not find channel named "file10"

ps x
29458 ? Z 0:00 [eggdrop] <defunct>
29459 ? Z 0:00 [services] <defunct>
29460 ? Z 0:00 [neostats] <defunct>
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

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...
Post Reply