GodOfSuicide wrote:is it possible to use open the way i just told ?
Yes. By using 'fconfigure' to make it non-blocking and 'fileevent readable' to set up the callback. The only thing that is a bit tricky is redirection of stderr...i'll get back to you on this...try this code:
proc myexec {cmd callback} {
set f [open |$cmd r+]
fconfigure $f -blocking 0
fileevent $f readable [list myexecIn $f $callback]
set f
}
proc myexecIn {f callback} {
if {[set i [gets $f line]]>0} {
uplevel #0 [concat $callback [list $line]]
} elseif {$i==-1} {
close $f
uplevel #0 [concat $callback {{}}]
}
}
The callback command will be called for each line of output. Blank lines are ignored and when the process ends the callback command is called with a blank argument - like a dcc connection put under control under eggdrop. (the callback can be a list of command+arguments just like the built in callbacks.) This code is by no means final, but it's something to start with