问题描述
我想在 tcl 脚本中执行以下命令。该命令与特定工具相关。
exec tool cut Netlists/$::env(DESIGN_NAME).netlist.v
当上述命令在运行 tcl 脚本时执行时,其相应的输出不会显示在终端上。
当我尝试在 tcl shell 中运行此命令时,它工作正常。
有没有办法在终端上打印结果?
解决方法
如果你希望输出被定向到终端,你需要添加重定向(否则输出成为exec
命令的Tcl结果)。这是通过附加 >@stdout 2>@stderr
来完成的(您通常希望重定向输出和错误流)。
exec tool cut Netlists/$::env(DESIGN_NAME).netlist.v >@stdout 2>@stderr
如果你要经常做这件事,有一个辅助程序会有所帮助:
proc tool {args} {
# You might do other things here,like logging what command was actually called
exec tool {*}$args >@stdout 2>@stderr
}
tool cut Netlists/$::env(DESIGN_NAME).netlist.v