Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Pblm: echo invalid command!

718 views
Skip to first unread message

Tracy Sweat

unread,
Feb 3, 1996, 3:00:00 AM2/3/96
to
I recently downloaded tcl7.4 and tk4.0. I installed them in my home
directory on my Sun workstation at work. If I start tclsh and enter
the echo command interactively from the keyboard it works as advertised.
But when I write a short program and save it in a file, I can neither
make it executable (starting with the usual #!pathname/tclsh) nor
source it without all the echo commands returning invalid command errors.
Any ideas why this is happening?

TIA.

Take care,


Tracy
tsw...@flash.net


Sean Kelly

unread,
Feb 5, 1996, 3:00:00 AM2/5/96
to

"echo" is not a tcl command.

When you run tclsh interactively and type commands, tcl looks them up
and executes them. If there's one it doesn't know about, like "echo",
it then tries to execute a program with that name. On a Sun, it
probably executes /usr/bin/echo or /bin/echo.

This works due to tcl's "unknown" handler. See the "unknown" man page
or the _Tcl and the Tk Toolkit_ book for more info.

Now, when you make a script file, note these things:

* Make the file executable: chmod +x <file> or chmod 755 <file> should
enough.

* Make the first line contain `#!' plus the path to the tclsh
executable, such as: ``#!/home/kelly/bin/tclsh''

* The first line has to be less than the operating system limit (which
varies) of about 30 characters. #!/home/kelly/local/src/eeep/fish/bin/tcslh
won't work!

* When you make a script, the "unknown" command *isn't* set up to
execute unknown commands as external programs. So "echo" won't
work!

Finally, in Tcl, the command you want is "puts", not "echo".

--k

Mike Hopkirk

unread,
Feb 9, 1996, 3:00:00 AM2/9/96
to

In article <4f5qu3$t...@peabody.colorado.edu> ke...@emu.fsl.noaa.gov (Sean Kelly) writes:

>Path: hobbes.sco.COM!sgiblab!sgigate.sgi.com!swrinde!newsfeed.internetmci.com!in1.uu.net!boulder!emu.fsl.noaa.gov!kelly
>From: ke...@emu.fsl.noaa.gov (Sean Kelly)
>Newsgroups: comp.lang.tcl
>Date: 5 Feb 1996 20:56:35 GMT
>Organization: Forecast Systems Laboratory
>Lines: 30
>References: <4eun0f$q...@bounty.flash.net>
>NNTP-Posting-Host: emu.fsl.noaa.gov


>
>
>"echo" is not a tcl command.

but it is a tclX command - just about enough to make it worthwhile adding
that extension just for that capability ....

> ...


>
>Finally, in Tcl, the command you want is "puts", not "echo".

with the proviso that puts only takes a single data argument so you have
to quote or variablise things ..

tcl>puts a
a
tcl>puts a b
Error: bad file identifier "a"
tcl>puts stderr a
a
tcl>puts a
a
tcl>puts a b
Error: bad file identifier "a"
vtcl>puts a b c
Error: bad argument "c": should be "nonewline"
--
- hops

Everything disclaimed (including disclaimer)
------< ho...@sco.com>--------------------------------------
Mike Hopkirk ( hops ) | Whenever possible steal code.
SCO Inc | Tom Duff. Bell Labs


0 new messages