I'm trying to execute a silly 'for' loop in tcl :
for {set i 0} {$i < 10} {incr i} {
puts $i
}
but I get this error :
line 1: syntax error near unexpected token 'i'
line 1: 'for {set i 0} {$i < 10} {incr i} {'
It appears that your script is not being evaluated by Tcl, as that is definitely not an error message that Tcl generates (unless you write code to do so explicitly, i.e., not in this case!) It looks like it might be being evaluated by bash.
Try running your script like this (with the right filename, of course):
tclsh yourscript.tcl
If that works, change the start of your script to read:
#!/usr/bin/env tclsh
After that, just code normally as before.
There are other initial incantations that are somewhat popular:
#!/usr/bin/tclsh
#!/bin/sh
# some comment with a backslash at the end of the line \
exec tclsh "$0" ${1+"$@"}
But these are not as good as using /usr/bin/env which is simple, reliable and portable.
tclsh test.tcl. Could it be that you use a wrong intepreter, like bash?