fileevent
を使用してファイルをテールしようとしています(Tcl 8.4バージョンのみでなければならないので、chan
コマンドを使用できません)。fileeventを使用してローカルファイルをテールします
% proc GetData {chan} {
set data [read $chan]
puts "[string length $data] $data"
if {[eof $chan]} {
fileevent $chan readable {}
}
}
%
%
%
% set fp [open "|tail -f /home/dinesh/input" r+]
file7
% fconfigure $fp
-blocking 1 -buffering full -buffersize 4096 -encoding utf-8 -eofchar {{} {}} -translation {auto lf}
% fconfigure $fp -blocking 0 -buffering line
%
%
%
%
% fileevent $fp readable [list GetData $fp]
%
私は別の端末でcat
コマンドを使用してファイルの内容を変更しましたが、それでもGetData
は呼び出さ取得されていません。
gets $fp line
では、変更されたコンテンツを取得できますが、なぜfileeventがトリガーされないのですか?
ありがとうDonal !!!できます。あなたは素晴らしいです!!! – Dinesh