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 

Exec without ping timeout.

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


Joined: 02 Jun 2007
Posts: 13

PostPosted: Sun Aug 12, 2007 7:03 pm    Post subject: Exec without ping timeout. Reply with quote

So I'm executing pisg with a HUGE logfile, but most of the time it disconnects the eggdrop with ping timeout because it takes like 2 and a half minutes for pisg to analyse it.

Now, is there a way to execute pisg without being disconnected?

Thanks in advance. (if you want, ill post the tcl script)
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Sun Aug 12, 2007 8:13 pm    Post subject: Reply with quote

There is the option of using the open command with pipes.

Something like this should be a good start:
Code:
proc readpipe {fid} {
 if {![eof $fid]} {
  putlog "pisg: [gets $fid]"
 } {
  close $fid
 }
}

set fid [open "|pisg bla ..." "RDWR"]
fconfigure $fid -blocking 1
fileevent $fid readable [list readpipe $fid]

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


Joined: 02 Jun 2007
Posts: 13

PostPosted: Sun Aug 12, 2007 9:06 pm    Post subject: Reply with quote

and this wont cause a ping timeout? because if I get this right, i open pisg, and read it until its closed, but then, it takes 3 minutes to close because it takes 3 minutes for pisg to analyse the log.

If i'm wrong please tell me so, thanks for the reply btw!
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Sun Aug 12, 2007 9:16 pm    Post subject: Reply with quote

The trick here is, output is read as it comes available, being triggered by an event-handler, while "exec" will block until the execution is complete (thus causing your bot becoming unresponsive for several minutes and ping timeout). The "open" command will return instantly, providing a file-handle which you can pretty much use just like any other file, except that you're writing to the program's stdin, and reading from it's stdout.

The "fileevent" command is what sets up the event-handler to track the opened pipe for a readable-condition, at which readpipe will be called to look for an eof-condition, and try to read one line.
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Alchera
Revered One


Joined: 11 Aug 2003
Posts: 3344
Location: Ballarat Victoria, Australia

PostPosted: Sun Aug 12, 2007 9:18 pm    Post subject: Reply with quote

Simple solution is to not use eggdrop to do something that can be done far better server side.
_________________
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
Back to top
View user's profile Send private message Visit poster's website
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Mon Aug 13, 2007 12:20 am    Post subject: Reply with quote

I'd make a little shell script to run pisg, and then run that shell script from cron. I posted an example shell script to do just that, in the shell help forum (it also uploads the stats page to an ftp site if you need that as well.)
Back to top
View user's profile Send private message
leandro
Voice


Joined: 02 Jun 2007
Posts: 13

PostPosted: Mon Aug 13, 2007 6:40 am    Post subject: Reply with quote

Thanks all.

I'll first try the open trick to see if it fits my needs. If not, I'll make that cron script.

Thank you very much.
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