如何将标准输出重定向到 tcl 中的文件 [英] How can I redirect stdout into a file in tcl
本文介绍了如何将标准输出重定向到 tcl 中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将 proc 输出重定向到 tcl 中的文件,例如,我有一个 proc foo,并且想将 foo 输出重定向到文件 bar 中.但是得到了这个结果
how can I redirect a proc output into a file in tcl, for example, I have a proc foo, and would like to redirect the foo output into a file bar. But got this result
% proc foo {} { puts "hello world" }
% foo
hello world
% foo > bar
wrong # args: should be "foo"
推荐答案
这应该有效:
% proc foo {} { return "hello world" }
% foo
hello world
% exec echo [foo] > bar
% exec cat bar
hello world
% exec echo [foo] >> bar
% exec cat bar
hello world
hello world
%
这篇关于如何将标准输出重定向到 tcl 中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文