The problem you've got is that while it is running in Tcl (I recognize that format of trace), the Expect package (which provides the spawn
command) is absent for some reason. The first thing to do is to make the requirement for the Expect package explicit by uncommenting that package require
line. That may be enough to fix your problem in itself, but if not it will complain about the package not being available. If it's not available, that means either that it just isn't installed, or that it's not being found. The former is... obvious to fix. :-) The latter is resolved by putting a line like this before that package require
:
lappend auto_path /full/path/to/Expect/package/installation
Note that if you run the script with the expect program instead of the tclsh program, that package require
will be done for you automatically. You're obviously not doing that…