我有这个功能,
proc get_sys_status aname {
upvar $aname a
set input [exec "get system status\n" "# "]
set linelist [split $input \n]
foreach line $linelist
{
if {![regexp {([^:]+):(.*)} $line dummy key value]}
continue
switch -regexp -- $key
{
Hostname
{
set a(hostname) [string trim $value]
}
}
}
}
get_sys_status status
# line 17
puts "This machine is called $status(hostname)"
一般的想法是它接受命令“get system status”的输出并解析数据。解析之后,它会抓取主机名并使用它来向框发出一些命令。第17行(最后一行)出现错误:
can't read "status(hostname)": no such variable
----An error occured at line #17 of the script----
------- The end of log ----------
这个功能出了什么问题?