由于第11行而无法执行tcl脚本:意外令牌附近的语法错误`}'

0 tcl

附上是我的代码.但是,当我执行它时,出现此错误消息:第11行:意外标记附近的语法错误`}'

由于我是tcl的新手,我不知道哪里出了问题.请帮忙 !!!非常感谢

 set filename "a.qip"
 set temp [create_temp_file a.qip]
 set out [open $temp w]
 set in [open $filename r]
 set entityname "edward"

 while {[gets $in line] != -1} {
       if {[string match "*SDC_FILE*" $line]} {
        puts $out $line
        puts $out "set variant_name $entityname"
     } else {
          puts $out $line
     }
 }
    close $in
    close $out 

file link -hard $filename a.qip.bak
file rename -force $temp $filename
Run Code Online (Sandbox Code Playgroud)

gle*_*man 6

您正在尝试使用它sh来解释您的Tcl文件:

$ sh f.tcl
f.tcl: line 11: syntax error near unexpected token `}'
f.tcl: line 11: `     } else {'
Run Code Online (Sandbox Code Playgroud)

你需要使用 tclsh

$ tclsh f.tcl
invalid command name "create_temp_file"
    while executing
"create_temp_file a.qip"
    invoked from within
"set temp [create_temp_file a.qip]"
    (file "f.tcl" line 2)
Run Code Online (Sandbox Code Playgroud)