XPS-Q8
Tcl Manual
4.2
“Hello world !” Example
4.2.1
Tcl script example
The following Tcl script example shows how to display a message in a telnet window.
# Set channel’s name to be used for telnet.
# In this example we assume it is passed to the script as the
# first argument, if not specified output to stdio.
# Open the channel for read mode and get its id,
# this is the id that will be passed to puts function.
if
{$tcl_argv(
0
) !=
0
} {
set
telnetOut [
open
"/dev/$tcl_argv(
0
)" r+]
} else {
set
telnetOut stdout
}
# display hello world message
puts
$telnetOut "Hello world !"
# Force transfer to channel’s output buffer
flush
$telnetOut
4.2.2
Tcl script execution
When you open a telnet session you can see the channel’s identifier as shown below:
The channel identifier will be used as argument for the function called from Terminal to
execute the Tcl script:
EDH0307En1041 — 10/17
17