tclsh
Run Tcl scripts
SYNOPSIS
tclsh [script] [args]
PARAMETERS
script
The name of a Tcl script file to be executed. If provided, tclsh will execute the script and exit. Any subsequent arguments are passed to the script as command-line arguments.
args
Arguments passed to the Tcl script, accessible within the script using the argv and argc variables.
DESCRIPTION
The tclsh command initiates the Tcl (Tool Command Language) shell, an interactive interpreter for executing Tcl scripts. It provides a command-line environment where users can enter Tcl commands directly and see their results immediately. This makes tclsh extremely useful for prototyping, testing, debugging Tcl code, and performing quick system administration tasks.
tclsh reads Tcl commands from standard input or from a file specified as an argument. When no file is provided, tclsh enters interactive mode, displaying a prompt (usually '% ') and waiting for user input. It then evaluates each command and prints the result to standard output. Tclsh is a versatile tool found in virtually any Linux distribution that supports Tcl scripting, offering a powerful means of interacting with the system and manipulating data using the Tcl language.
STARTUP SCRIPT
When tclsh starts, it searches for a startup script, typically named .tclshrc or tclshrc.tcl, in the user's home directory or a system-wide Tcl library directory. This script is automatically executed, allowing you to customize the tclsh environment, define commonly used procedures, or load extensions.
EXITING TCLSH
To exit tclsh in interactive mode, you can use the exit command or press Ctrl+D (end-of-file).
SECURITY CONSIDERATIONS
Running untrusted Tcl code can expose the system to risks. Tcl provides 'safe' interpreters using the 'safe base' which limit the command set to protect the system.
HISTORY
Tcl (Tool Command Language) was created by John Ousterhout at the University of California, Berkeley, in the late 1980s. Tclsh, as the standard Tcl shell, evolved along with the language. Its initial purpose was to provide a simple yet powerful scripting language suitable for a variety of tasks, including GUI development (with Tk), system administration, and embedded systems. Tclsh saw rapid adoption in many domains, becoming an essential part of many software development environments.
SEE ALSO
wish(1), expect(1), tcl(n)