Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the version of TCL from the command-line?

Tags:

tcl

I'm looking for a very straight-forward way of getting the version of the TCL installed on a machine from the command-line. For most programming languages, something along the lines of

languagename -v

provides the information that I want. This does not seem to be an option for tclsh.

The TCL FAQ Q.B21 suggests

echo 'puts $tcl_version;exit 0' | tclsh

but I wonder if there is anything more straight-forward and cross-platform? (I suspect that this would fail mightily on a Microsoft Operating System.)

--

EDIT: Just to emphasize that I'm looking for something that can be executed directly from the operating system command-line. There's all kinds of information available once you start tclsh, but I'm trying to avoid that to ease automated discovery.

like image 643
Simon Peter Chappell Avatar asked Feb 08 '12 19:02

Simon Peter Chappell


People also ask

How do I know my Tcl version?

Open a command prompt to test the install, type in "tclsh" which should open an interactive tcl console. Enter "info patchlevel" to check the version of tcl that was installed and it should display an output of the form "8.6.

How do I run a Tcl script from the command line?

You can run this program by starting tclsh from the start menu, then typing the command source c:/hello. tcl. Note that the traditional Windows \ is replaced with /. to your script.

Is update a TCL command?

The update idletasks command is useful in scripts where changes have been made to the application's state and you want those changes to appear on the display immediately, rather than waiting for the script to complete. Most display updates are performed as idle callbacks, so update idletasks will cause them to run.

What is command in Tcl?

In SQL, TCL stands for Transaction control language. A single unit of work in a database is formed after the consecutive execution of commands is known as a transaction. There are certain commands present in SQL known as TCL commands that help the user manage the transactions that take place in a database. COMMIT.


3 Answers

This might sound too simplistic, but if you made a script file that contained the commands:

puts $tcl_version

And then ran tclsh sillyscript.tcl, that would execute on all platforms, assuming binary is in PATH. It certainly isn't fancy or flashy, or even neat, but it satisfies that requirement AFAIK.

====

I got curious, so I tried it and without the quotes:

echo puts $tcl_version;exit 0 | tclsh

Executes just fine on my windows box... maybe platform detection prior to the TCL detection is an option?

like image 159
Niall Byrne Avatar answered Oct 21 '22 09:10

Niall Byrne


you can do this too.

bash-3.2$ tclsh
% puts $tcl_version
8.6
% info patchlevel
8.6.0

but the best way i think is through echo.

echo 'puts [info patchlevel];exit 0' | tclsh
echo 'puts $tcl_version;exit 0' | tclsh

=======

weird when i tried with out the quotes it didn't work for me. running Mac osx

like image 27
Darkninja Avatar answered Oct 21 '22 08:10

Darkninja


Depending on your shell, it could be:

tclsh <<< 'puts [info patchlevel]'
like image 12