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.

Exec without ping timeout.

Help for those learning Tcl or writing their own scripts.
Post Reply
l
leandro
Voice
Posts: 13
Joined: Sat Jun 02, 2007 9:43 am

Exec without ping timeout.

Post by leandro »

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)
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

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

Something like this should be a good start:

Code: Select all

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
l
leandro
Voice
Posts: 13
Joined: Sat Jun 02, 2007 9:43 am

Post by leandro »

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!
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

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
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

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
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

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.)
l
leandro
Voice
Posts: 13
Joined: Sat Jun 02, 2007 9:43 am

Post by leandro »

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