2017-01-12 155 views
0

我是从当前脚本看到这个“无效的命令名称错误”的TCL脚本只检查包的正确版本安装或没有调用脚本(tclscript)。

#!/bin/tclsh 
# i am doing this for multiple packages in a loop 
set list {/usr/local/script} 
lappend list -check 
lappend list -package 
lappend list tcl-devel 
lappend list version 

[eval exec $list] 

输出:

invalid command name " 
checking the version [ ok ] #expected output 
-checks successful!   #expected output 
" 
    while executing 
"[eval exec $list]" 

不明白为什么我得到这个“无效的命令名称错误”谁能帮助调用从另一个TCL脚本Tcl脚本与多个arguements

+1

尝试围绕EVAL去掉括号...名单。 –

回答

0

的问题是,你已经成功运行了命令,已经得到了结果回去,然后尝试,因为你把[括号]eval exec各地使用这些结果作为命令的名称。要么删除括号,要么在它们前面放置一个命令名称,以便将结果用作参数。

set list … 
# Leaving out the details of how you build the list 

eval exec $list 
set list … 
# Leaving out the details of how you build the list 

set result [eval exec $list] 
puts "result is \"$result\"" 
+0

另外,如果您的Tcl版本是目前支持的版本,请将'eval exec $ list'切换到'exec {*} $ list'。 –