hmm ive read about file event its a binding that starts when a specific channel gets readable or writeable .. , but what about when a channel closes , i got a script that open exe "r+" after a few minutes when it ends (channel closes) i would like to trigger a trigger to perfom a script .. how would i do this .. ?? ive been looking true the manual and euhm can't find sutch thing . ? any one who can help me out ?
If you want to set up a fileevent, use readable as roland suggests. But I'd caution that the if data = "" thing isn't necessarily true. If you're using gets, for instance, it will return "" if there is an incomplete line, or simply a blank line. A less fallible way to check for the channel closing is just to use the [eof] command like ppslim does in his code. To combine the two, it's something like this:
set fp [open |blah.exe r+]
fconfigure $fp -blocking 0
fileevent $fp readable [list on_readable $fp]
proc on_readable {fp} {
set len [gets $fp line]
if {$len > 0} {
# got a line, do whatever you want with it
} elseif {[eof $fp]} {
close $fp
# program terminated
}
return 0
}
tnx for the scripts and i will test em sorry for the answer delay .. :/ was not home hehe for few days hehe so but ill test em for sur tnx in advance this surtanly will give me new ideas
what you exactly mean by this ? just curious i mean is there where i put the info or is it just some info you added to make the code understandable .. ?