Skip to Content
Exploring Expect
book

Exploring Expect

by Don Libes
December 1994
Intermediate to advanced
606 pages
16h 7m
English
O'Reilly Media, Inc.
Content preview from Exploring Expect

Sending Character Graphics

In Chapter 6 (p. 140), I described how to handle spawned programs that generate character graphics. It is occasionally useful to generate character graphics from the script itself. Expect provides no built-in support for doing this. It is not necessary because you can call external programs such as tput.[45] For example, the cup operation moves the cursor. The following command moves it to row 23, column 4:

send_user -raw [exec tput cup 23 4]

Executing many calls to tput can be slow because it is a separate program. However, its different outputs can be saved in variables and reused, thereby avoiding excessive calls of exec. More sophisticated handling is possible with Curses extensions to Tcl. These are listed in the Tcl FAQ.

[45] Probably a more significant reason that Tcl scripts do not perform character graphics is because of Tk, a Tcl extension for the X Window System. Tk is so easy to use that it is hard to justify spending time writing character-graphic interfaces when the same amount of time can produce a much better interface in X. I will describe the use of Tk with Expect in Chapter 19 (p. 428).

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

AI Agents in Action

AI Agents in Action

Micheal Lanham
Learning Go

Learning Go

Jon Bodner

Publisher Resources

ISBN: 9781565920903Supplemental ContentErrata Page