Hello and thanks for coming here...
First off, this is my first attempt at TCL scripting. I have been reading
thru the ActiveTCL manuals alot lately. Now I am trying to build a proc
that will do the following:
open a channel "in"
read in some logfiles in a dir "logdir"
close channel "in"
foreach of these files read them and lappend to a variable "log_data"
open a new channel "out" and puts the collected (read) $log_data
then close channel "out"
return with the logfile argument of this proc that was used as file for the open "out"]
So in the end I have a file "logfile" created by "out" that contains all
the data read by "in". And I have the ability to store the return code by
the proc in a new variable so I can work with the location of "logfile".
Here's what I have so far:
Code:
proc savePrelog {dir logfile} {
set prelog_data {}
foreach file [glob -nocomplain -directory $dir *{underdogs}*.log] {
set line [gets $in]
set dataIN [read $in]
close $in
lappend prelog_data $dataIN
set out [open $logfile a]
set dataOUT $prelog_data
puts $out $dataOUT
close $out
}
return $logfile
}
but this way I have the problem that it does not stop once it has
read all logfiles. The saved file just grows and grows...
There must be a way to do this properly.
Thanks for any replies
Cheers
DJ