UNIX Tcl Scripts
On UNIX you can create a stand alone Tcl or Tcl/Tk script much like an sh or csh script. The trick is in the first line of the file that contains your script. If the first line of a file begins with #!pathname, then UNIX uses pathname as the interpreter for the rest of the script. The “Hello, World!” program from Chapter 1 is repeated in Example 2-1 with the special starting line:
Example 2-1 A standalone Tcl script on UNIX.
#!/usr/local/bin/tclsh puts stdout {Hello, World!} |
Similarly, the Tk hello world program from Chapter 21 is shown in Example 2-2:
Example 2-2 A standalone Tk script on UNIX.
#!/usr/local/bin/wish button .hello -text Hello -command {puts "Hello, World!"} pack .hello -padx 10 -pady 10 |
The actual pathnames ...
Get Practical Programming in Tcl & Tk, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.