DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

VtAddInput(VTCL)


VtAddInput -- add a callback on file activity (read, write, error)

Syntax

VtAddInput fileID cmd

Description

Register a command or procedure callback that is called when an I/O stream is ready for file activity. When the stream referenced by fileID becomes readable, writable or in error, the callback command registered is called with the fileID as its argument. You can then read and write to the stream without fear of the interpreter blocking.

Notes

You must execute VtMainLoop(VTCL) to allow the callback to be called.

Example

The following code fragment illustrates the use of VtAddInput to filter the output of a UNIX system command, in this case find.
   proc dumpFoundCB {fid} {
   

set count 1 while { $count > 0 } { set count [gets $fid line] ;# read a line of input puts stdout ">> $line" } if { $count == -1 } { ;# end of file echo "\n\nFinished" exit 0 } }

set cmd {| /bin/find /usr -name "*" -print}

# open the pipe if [catch {set f [open $cmd ] } msg ] { echo "open failed" exit 1 }

#setup read handler on it.. VtAddInput $f dumpFoundCB VtMainLoop


© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003