Reputation: 1
Attached is my code . However when i execute it ,this error message come out :line 11: syntax error near unexpected token `}'
Since i am new to tcl , i dont know where is going wrong. please help !!! Many thanks
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
Upvotes: 0
Views: 2745
Reputation: 36
If your file a.qip contains specific char like curlies '{' and '}', it will be misinterpreted by the string match.
Upvotes: 0
Reputation: 246744
You are trying to use sh
to interpret your Tcl file:
$ sh f.tcl
f.tcl: line 11: syntax error near unexpected token `}'
f.tcl: line 11: ` } else {'
You need to use 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)
Upvotes: 6