egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Need a script to start some applications on my shell

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
tessa1
Halfop


Joined: 18 Apr 2005
Posts: 49
Location: Germany

PostPosted: Fri Mar 24, 2006 6:09 pm    Post subject: Need a script to start some applications on my shell Reply with quote

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
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Tue Mar 28, 2006 1:23 am    Post subject: Re: Need a script to start some applications on my shell Reply with quote

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
View user's profile Send private message Visit poster's website
tessa1
Halfop


Joined: 18 Apr 2005
Posts: 49
Location: Germany

PostPosted: Tue Mar 28, 2006 3:32 pm    Post subject: Re: Need a script to start some applications on my shell Reply with quote

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 Wink

Best regards
Back to top
View user's profile Send private message
tessa1
Halfop


Joined: 18 Apr 2005
Posts: 49
Location: Germany

PostPosted: Wed Mar 29, 2006 10:38 am    Post subject: Reply with quote

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? Smile

Best regards
Back to top
View user's profile Send private message
De Kus
Revered One


Joined: 15 Dec 2002
Posts: 1361
Location: Germany

PostPosted: Wed Mar 29, 2006 1:22 pm    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
tessa1
Halfop


Joined: 18 Apr 2005
Posts: 49
Location: Germany

PostPosted: Wed Mar 29, 2006 2:08 pm    Post subject: Reply with quote

I don't know, what is wrong with the braces.
Back to top
View user's profile Send private message
De Kus
Revered One


Joined: 15 Dec 2002
Posts: 1361
Location: Germany

PostPosted: Wed Mar 29, 2006 7:58 pm    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Wed Mar 29, 2006 11:12 pm    Post subject: Reply with quote

...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
View user's profile Send private message Visit poster's website
tessa1
Halfop


Joined: 18 Apr 2005
Posts: 49
Location: Germany

PostPosted: Thu Mar 30, 2006 10:32 am    Post subject: Re: Need a script to start some applications on my shell Reply with quote

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
View user's profile Send private message
tessa1
Halfop


Joined: 18 Apr 2005
Posts: 49
Location: Germany

PostPosted: Thu Mar 30, 2006 10:46 am    Post subject: Reply with quote

I hope, this is right now Smile

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
View user's profile Send private message
tessa1
Halfop


Joined: 18 Apr 2005
Posts: 49
Location: Germany

PostPosted: Thu Mar 30, 2006 1:07 pm    Post subject: Reply with quote

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
View user's profile Send private message
De Kus
Revered One


Joined: 15 Dec 2002
Posts: 1361
Location: Germany

PostPosted: Thu Mar 30, 2006 9:51 pm    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber