I had someone give me this example script to work on and was wondering if 
anyone could enlighten me on how to get it to work.

I am running on a solaris sparc, but given that it should really work in
windows as well, as long as the filenames it points too are changed.

Currently what I am trying to do is bring up a display window with 
an active log file being displayed into it.

I can get the window up and it just doesn't through the output of the 
logfile into the window though.

Perhaps someone who is much more experienced than me, could look it over 
and point out any glaring mistakes?

Thanks go to Mr. Jim Kraai for letting me have this script.

#!/usr/bin/wish
proc got_new_data {filehandle} {
uplevel 0 {.text insert end [format "%s\n" [gets $filehandle]]}
}
#
# The rest of the procedures, etc.
#
# A widget to put the text in
text .text
pack .text -expand 1 -fill both -side top
set filename "/var/log/messages"
# Note n is the number of initial lines you asked for
set n 3
# Get the file handle
# I might have been format-happy when I wrote this
set pipe_cmd [format "|tail -f -%s %s" $n $filename]
set in_handle [open $pipe_cmd]
fconfigure $in_handle -blocking 0
# Get those first n lines
for {set i 1} {$i < $n} {incr i} {
  got_new_data $in_handle
 }
# Set the fileevent
fileevent $in_handle readable [list got_new_data $in_handle]

---------------------------------------------------------------------------
To unsubscribe from the Visual Tcl mailing list, please send a message
to [EMAIL PROTECTED] with "unsubscribe vtcl [EMAIL PROTECTED]" in the
message body (where [EMAIL PROTECTED] is your e-mail address).

Reply via email to