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.

Shell execution with flood protection & capturing output

Old posts that have not been replied to for several years.
Locked
S
Sho

Shell execution with flood protection & capturing output

Post by Sho »

I badly need a script to do the following:

1. React to a a public command in the form of "!command"
2. Execute something on the shell (Unix)
3. Set a timer so repeating of "!command" in short succession on the channel doesn't work for another X minutes (as a safeguard against flooding / bringing down the machine)
4. Scan the output of the shell command until a certain line shows up (execution time may be up to two minutes, output is a couple of lines)
5. Once that line has been registered, send some text to the channel

Any pointers? Any existing script that lends itself to be modified for this purpose? Anyone willing to whip something up quickly?
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

this will spawn the supplied UNIX command in background, displaying its output as soon as such is available, disabling running new commands until current one is completed (not tested):

Code: Select all

set inuse 0
bind pub n !exec foo
proc foo {n u h c t} {
  if !$::inuse {
    set ::inuse 1; set f [open "|$t"]
    fconfigure $f -blocking 0 -buffering line
    fileevent $f readable "moo $f $c"
  }  
}
proc moo {f c} {
  puthelp "privmsg $c :[gets $f]"
  if [eof $f] {set ::inuse 0; close $f}
}
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

remember if its windrop then it needs to run in forground mode
XplaiN but think of me as stupid
Locked