【发布时间】:2014-09-24 13:57:07
【问题描述】:
我正在使用 open 命令从 tcl 打开一个 shell 程序,shell 输出文件逐行包含一些 stings 和 tcl 命令。任何人都可以告诉我如何打印该行是否是字符串列表以及如何评估该行是否是一个 tcl 命令
我使用了以下 sytnax,但它也在尝试执行字符串,
set fileID [open "| unix ../filename_1" r+]
while 1 {
set line [gets $fileID]
puts "Read line: $line"
if {$line == "some_text"} { puts $line #text
} elseif { $line == "cmd"} {set j [eval $line] #eval cmd }
}
【问题讨论】: