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 

launching a proc in background?

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
needHelp
Voice


Joined: 03 Nov 2007
Posts: 2

PostPosted: Sat Nov 03, 2007 8:31 pm    Post subject: launching a proc in background? Reply with quote

hi, i wrote a proc for my eggdrop which takes some time.
while running this proc the eggdrop cant respond to other commands and sometimes i get ping timeout.

the proc has to take the long time so i dont want to change anything on it.

instead im looking for a method to call the proc from the binded proc to launch in background or in a child process.

i already tried forking but without success.

any1 here has an idea?

thx in advance.
Back to top
View user's profile Send private message
TCL_no_TK
Owner


Joined: 25 Aug 2006
Posts: 509
Location: England, Yorkshire

PostPosted: Sun Nov 04, 2007 10:34 pm    Post subject: Reply with quote

I dont know if thats really possible, thou it all depends on what the script dose? If its something like running a progeram or an exacutable, that would probably ...i would think could easyerly be done. But other than that, i could recommend execting tclsh and running it that way? or use of a pipe or unix sock maybe?
_________________
TCL the misunderstood
Back to top
View user's profile Send private message Send e-mail
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Mon Nov 05, 2007 10:02 am    Post subject: Reply with quote

Could usually be done quite easily..

Depending on system, this might work:
Code:
exec -- command &


A slightly more complicated approach, that also allows you to access the stdin and stdout pipes through file-handles
Code:
proc readcmd {process} {
 if {[gets $process data] < 0} {
  if {[eof $process]} {
   close $chan
   return
  }
 } {
  #Process the output stored in $data, or just ignore it?
 }
}

set pid [open "| command" "RDWR"]
fconfigure $pid -blocking 0
fileevent $pid -readable [list readcmd $pid]

_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
needHelp
Voice


Joined: 03 Nov 2007
Posts: 2

PostPosted: Mon Nov 05, 2007 11:29 am    Post subject: Reply with quote

as i already said i dont want to run an executable.

But i think i solved it on my own using Thread 2.6 package.
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Mon Nov 05, 2007 3:04 pm    Post subject: Reply with quote

Another (silly?) solution could be the use of a timer (1 seconde) to launch your proc.
_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Mon Nov 05, 2007 6:57 pm    Post subject: Reply with quote

Registering a timer would still cause it to be executed within the same thread, causing the same blocking condition.
I have no experience using the Thread package with eggies myself, would be nice to hear if it goes all well.
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help 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