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

Tk And tkinspect

The Tk extension to Tcl provides commands that are primarily used for the purpose of building graphic user interfaces. However, one Tk command that has nothing to do with graphics is the send command.[61]Tk’s send command sends a command from one Tk application to another. The command is evaluated by the second application and returned to the first.

An obvious command to send to an application is "set foo" to find out, for example, what the value of foo is. To do this, all you have to do is send the command from another Tk application. Below, I typed the shell command to start expectk—a program that combines Expect and Tk. Using expectk, I then sent to the application named frogger a request to get the value of the variable named frogcount:

% expectk
expect1.1> send frogger set frogcount
17

Because X applications typically spend most of their life waiting in an event loop, applications in Tk are almost always ready to respond to send requests. The applications do not have to do anything special to handle them. Most importantly, applications do not have to be stopped to handle them. Tk applications process send requests as they are received. This makes the send command quite useful for debugging. Without any preparation, you can pry into the internal data structures of scripts while they are running!

In fact, you are not restricted to looking at variables. You can change variables. You can execute procedures. You can even redefine procedures as the script is running. ...

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