VtAddInput(VTCL)


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

Synopsis

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.

Examples

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

Notices

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

02 June 2005
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 - 02 June 2005