如何调用从Tcl脚本的bash命令? [英] How to call bash commands from tcl script?
问题描述
Bash的命令可以从一个交互式会话的tclsh。例如。在tclsh的会话,你可以有
Bash commands are available from an interactive tclsh session. E.g. in a tclsh session you can have
% ls
而不是
$ exec ls
不过,你不能有一个Tcl脚本它调用的bash命令直接(即无 EXEC
)。
我怎样才能让tclsh的认识而国米preting Tcl脚本文件的bash命令,就像它在交互式会话?
How can I make tclsh to recognize bash commands while interpreting tcl script files, just like it does in an interactive session?
我想有一些TCL封装(或类似的东西),它自动加载,而开展的交互式会话支持的bash commans的直接调用。我怎样才能在TCL脚本文件手动加载呢?
I guess there is some tcl package (or something like that), which is being loaded automatically while launching an interactive session to support direct calls of bash commans. How can I load it manually in tcl script files?
推荐答案
这是怎么回事的是,当你键入比如命令未知
proc已经得到调用 LS
,因为这不是一个现有的Tcl命令,默认情况下,该命令将检查如果命令是从一个交互式会话,并从顶层(而不是间接的调用进程内体),它的检查,看看是否在proc名称某处的路径上存在。您可以通过编写自己的PROC不明得到这样的事情。
What's going on here is that the unknown
proc is getting invoked when you type a command like ls
, because that's not an existing tcl command, and by default, that command will check that if the command was invoked from an interactive session and from the top-level (not indirectly in a proc body) and it's checking to see if the proc name exists somewhere on the path. You can get something like this by writing your own proc unknown.
有关这个良好的开端,检查的输出
For a good start on this, examine the output of
info body unknown
这篇关于如何调用从Tcl脚本的bash命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!