'Redirecting output of tcl proc to file and output (like tee)
I need redirect that I found in one of my searches:
redirect -tee LogFile.log {include ../RunDemoTests.tcl}
Where include is a TCL proc and ../RunDemoTests.tcl is a parameter to the proc. Is there a library I need to be able to use redirect or is this not general tcl?
I am working in an EDA tool environment that runs under both Windows and Linux, so I need a solution that is just TCL and does not rely on something from the OS.
I have tried numerous variations of:
set ch [open |[list include "../OsvvmLibraries/UART/RunDemoTests.tcl"] r]
set lf [open build.log w]
puts "Starting"
puts $lf "Starting"
while {[gets $ch line]>=0} {
puts $line
puts $lf $line
}
close $lf
However, this only seems to work when the command is something from the OS environment, such as:
set ch [open |[list cat ../tests.pro] r]
Printing from this can be a significant number of lines, buffering is ok, but not collecting the whole file and then printing as the files can be long (180K lines).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
