-
Chapter 1 Intro—What Is Expect?
-
Ouch, Those Programs Are Painful!
-
A Very Brief Overview
-
A First Script—dialback
-
Total Automation
-
Differing Behavior When Running Non-Interactively
-
Partial Automation
-
Dangerous, Unfriendly, Or Otherwise Unlikable User Interfaces
-
Graphical Applications
-
A Little More About Tcl
-
Job Control
-
Background Processes
-
Using Expect With Other Programs
-
Using Expect On UNIX
-
Using Expect On Other Operating Systems
-
Using Expect In Real Applications
-
Using Expect In Commercial Applications—Legalese
-
Obtaining Expect and the Examples
-
Expect And Tcl Resources
-
Exercises
-
-
Chapter 2 Tcl—Introduction And Overview
-
Everything Is A String
-
Quoting Conventions
-
Expressions
-
Braces—Deferring Evaluation
-
Control Structures
-
More On Expressions
-
Lists
-
More Ways To Manipulate Strings
-
Arrays
-
Indirect References
-
Handling Errors
-
Evaluating Lists As Commands
-
Passing By Reference
-
Working With Files
-
File I/O
-
Executing UNIX Commands
-
Environment Variables
-
Handling Unknown Commands
-
Libraries
-
Is There More To Tcl?
-
Exercises
-
-
Chapter 3 Getting Started With Expect
-
The send Command
-
The expect Command
-
Anchoring
-
What Happens When Input Does Not Match
-
Pattern-Action Pairs
-
Example—Timed Reads In The Shell
-
The spawn Command
-
The interact Command
-
Example—Anonymous ftp
-
Exercises
-
-
Chapter 4 Glob Patterns And Other Basics
-
The * Wildcard
-
More Glob Patterns
-
Backslashes
-
Handling Timeout
-
Handling End Of File (eof)
-
Hints On The spawn Command
-
Back To Eof
-
The close Command
-
Programs That Ignore Eof
-
The wait Command
-
Exercises
-
-
Chapter 5 Regular Expressions
-
Regular Expressions—A Quick Start
-
Identifying Regular Expressions And Glob Patterns
-
Using Parentheses To Override Precedence
-
Using Parentheses For Feedback
-
More On The timed–read Script
-
Pattern Matching Strategy
-
Nested Parentheses
-
Always Count Parentheses Even Inside Of Alternatives
-
Example—The Return Value From A Remote Shell
-
Matching Customized Prompts
-
Example—A Smart Remote Login Script
-
What Else Gets Stored In expect_out
-
More On Anchoring
-
Exercises
-
-
Chapter 6 Patterns, Actions, And Limits
-
Matching Anything But
-
Really Complex Patterns
-
Really Simple Patterns
-
Matching One Line And Only One Line
-
Tcl's string match Command
-
Tcl's regexp Command
-
Tcl's regsub Command
-
Ignoring Case
-
All Those Other String Functions Are Handy, Too
-
Actions That Affect Control Flow
-
Example—rogue
-
Character Graphics
-
More Actions That Affect Control Flow
-
Matching Multiple Times
-
Recognizing Prompts (Yet Again)
-
Speed Is On Your Side
-
Controlling The Limits Of Pattern Matching Input
-
The full_buffer Keyword
-
Double Buffering
-
Perpetual Buffering
-
The Politics Of Patterns
-
Expecting A Null Character
-
Parity
-
Length Limits
-
Comments In expect Commands
-
Restrictions On expect Arguments
-
eval—Good, Bad, And Ugly
-
Exercises
-
-
Chapter 7 Debugging Patterns And Controlling Output
-
Pattern Debugging
-
Enabling Internal Diagnostics
-
Logging Internal Diagnostics
-
Disabling Normal Program Output
-
The log_user Command
-
Example—su2
-
Recording All Expect Output
-
Sending Messages To The Log
-
About File Names
-
Log And Diagnostic State
-
Exercises
-
-
Chapter 8 Handling A Process And A User
-
The send_user Command
-
The send_error Command
-
The expect_user Command
-
Dealing With Programs That Reprompt
-
Dealing With Programs That Miss Input
-
Sleeping
-
Line Versus Character-Oriented And Other Terminal Modes
-
Echoing
-
Prompting For A Password On Behalf Of A Program
-
Security And Insecurity
-
Resetting The Terminal Upon Exit
-
More On The stty Command
-
The system Command
-
Redirecting The Standard Input Or Output
-
The expect_tty Command
-
The send_tty Command
-
Exercises
-
-
Chapter 9 The Expect Program
-
Expect—Just Another Program
-
Invoking Scripts Without Saying "expect"
-
Rewriting The #! Line
-
The .exp Extension
-
The—And Other Flags
-
The —c Flag
-
The -f Flag
-
Writing The #! Line
-
The −i Flag
-
The -n And -N Flags
-
The -d Flag
-
The -D Flag
-
The -b Flag
-
The - Flag
-
The interpreter Command
-
Exercises
-
-
Chapter 10 Handling Multiple Processes
-
The spawn_id Variable
-
Example—chess Versus chess
-
Example—Automating The write Command
-
How exp_continue Affects spawn_id
-
The Value Of spawn_id Affects Many Commands
-
Symbolic Spawn Ids
-
Job Control
-
Procedures Introduce New Scopes
-
How Expect Writes Variables In Different Scopes
-
Predefined Spawn Ids
-
Exercises
-
-
Chapter 11 Handling Multiple Processes Simultaneously
-
Implicit Versus Explicit Spawn Ids
-
Waiting From Multiple Processes Simultaneously
-
Example—Answerback
-
Which Pattern Goes With Which Spawn Id
-
Which Spawn Id Matched
-
Spawn Id Lists
-
Example—Connecting Together Two Users To An Application
-
Example—Timing All Commands
-
Matching Any Spawn Id Already Listed
-
The expect_before And expect_after Commands
-
Indirect Spawn Ids
-
Exercises
-
-
Chapter 12 Send
-
Implicit Versus Explicit Spawn Ids
-
Sending To Multiple Processes
-
Sending Without Echoing
-
Sending To Programs In Cooked Mode
-
Sending Slowly
-
Sending Humanly
-
Sending Nulls
-
Sending Breaks
-
Sending Strings That Look Like Flags
-
Sending Character Graphics
-
Comparing send To puts
-
Exercises
-
-
Chapter 13 Spawn
-
The Search Path
-
Philosophy--Processes Are Smart
-
Treating Files As Spawned Processes
-
Opening Ttys
-
Bugs And Workarounds
-
Process Pipelines And Ptys
-
Automating xterm
-
Checking For Errors From spawn
-
spawn -noecho
-
Example—unbuffer
-
Obtaining Console Output
-
Setting Pty Modes From spawn
-
Hung Ptys
-
Restrictions On Spawning Multiple Processes
-
Getting The Process Id From A Spawn Id
-
Using File I/O Commands On Spawned Processes
-
Exercises
-
-
Chapter 14 Signals
-
Signals
-
Signals In Spawned Processes
-
Notes On Specific Signals
-
When And Where Signals Are Evaluated
-
Overriding The Original Return Value
-
Using A Different Interpreter To Process Signals
-
Exit Handling
-
Exercises
-
-
Chapter 15 Interact
-
The interact Command
-
Simple Patterns
-
Exact Matching
-
Matching Patterns From The Spawned Process
-
Regular Expressions
-
What Happens To Things That Do Not Match
-
More Detail On Matching
-
Echoing
-
Avoiding Echoing
-
Giving Feedback Without -echo
-
Telling The User About New Features
-
Sending Characters While Pattern Matching
-
The continue And break Actions
-
The return Action
-
The Default Action
-
Detecting End-Of-File
-
Matching A Null Character
-
Timing Out
-
More On Terminal Modes (Or The -reset Flag)
-
Example—Preventing Bad Commands
-
Exercises
-
-
Chapter 16 Interacting With Multiple Processes
-
Connecting To A Process Other Than The Currently Spawned Process
-
Connecting To A Process Instead Of The User
-
Example—rz And sz Over rlogin
-
Redirecting Input And Output
-
Default Input And Output
-
Controlling Multiple Processes—kibitz
-
Combining Spawn Ids In A Single -input Or -output
-
Which Spawn Id Matched
-
Indirect Spawn Ids
-
An Extended Example—xkibitz
-
Exercises
-
-
Chapter 17 Background Processing
-
Putting Expect In The Background
-
Running Expect Without A Controlling Terminal
-
Disconnecting The Controlling Terminal
-
The fork Command
-
The disconnect Command
-
Reconnecting
-
Using kibitz From Other Expect Scripts
-
Mailing From Expect
-
A Manager For Disconnected Processes—dislocate
-
Expect As A Daemon
-
Example—Automating Gopher and Mosaic telnet Connections
-
Exercises
-
-
Chapter 18 Debugging Scripts
-
Tracing
-
Logging
-
Command Tracing
-
Variable Tracing
-
Example—Logging By Tracing
-
UNIX System Call Tracing
-
Tk And tkinspect
-
Traditional Debugging
-
Debugger Command Overview And Philosophy
-
Stepping Over Procedure Calls
-
Stepping Into Procedure Calls
-
Where Am I
-
The Current Scope
-
Moving Up And Down The Stack
-
Returning From A Procedure
-
Continuing Execution
-
Defining Breakpoints
-
Help
-
Changing Program Behavior
-
Changing Debugger Behavior
-
Exercises
-
-
Chapter 19 Expect + Tk = Expectk
-
Tk—A Brief Technical Overview
-
Expectk
-
The send Command
-
An Extended Example—tkpasswd
-
The expect Command And The Tk Event Loop
-
The expect_background Command
-
Multiple Spawn Ids In expect_background
-
Background Actions
-
Example—A Dumb Terminal Emulator
-
Example—A Smarter Terminal Emulator
-
Using The Terminal Emulator For Testing And Automation
-
Exercises
-
-
Chapter 20 Extended Examples
-
Encrypting A Directory
-
File Transfer Over telnet
-
You Have Unread News—tknewsbiff
-
Exercises
-
-
Chapter 21 Expect, C, And C++
-
Overview
-
Linking
-
Include Files
-
Ptys And Processes
-
Allocating Your Own Pty
-
Closing The Connection To The Spawned Process
-
Expect Commands
-
Regular Expression Patterns
-
Exact Matching
-
Matching A Null
-
What Characters Matched
-
When The Number Of Patterns Is Not Known In Advance
-
Expecting From Streams
-
Running In The Background
-
Handling Multiple Inputs And More On Timeouts
-
Output And Debugging Miscellany
-
Pty Trapping
-
Exercises
-
-
Chapter 22 Expect As Just Another Tcl Extension
-
Adding Expect To Another Tcl-based Program
-
Differences Between Expect And The Expect Extension In Another Program
-
Adding Extensions To Expect
-
Adding Extensions To Expectk
-
Creating Script-less Expect Programs
-
Functions And Variables In The Expect Extension
-
Exercises
-
-
Chapter 23 Miscellaneous
-
Random Numbers
-
Example—Generating Random Passwords
-
The Expect Library
-
Expect Versions
-
Timestamps
-
The time Command
-
Exercises
-
-
Appendix A Appendix—Commands and Variables
-
Commands And Flags
-
Variables
-
- Title:
- Exploring Expect
- By:
- Don Libes
- Publisher:
- O'Reilly Media
- Formats:
-
- Safari Books Online
- Print Release:
- December 1994
- Pages:
- 608
- Print ISBN:
- 978-1-56592-090-3
- | ISBN 10:
- 1-56592-090-2
Our look is the result of reader comments, our own experimentation, and feedback from distribution channels. Distinctive covers complement our distinctive approach to technical topics, breathing personality and life into potentially dry subjects. The animal featured on the cover of Exploring Expect is a chimpanzee, a primate of the Pongidae family, which also includes orangutans and gorillas. The chimpanzee is the mostly closely related to man of all animals, biochem ically, physiologically, behaviorally, and in brain structure. Chimpanzees are known to express emotions similar to those commonly associated with humans, including anger, affection, sadness, and happiness. They also display behavior similar to that of humans in their ability and inclination to pick up, examine, and manipulate objects. Until recently it was believed that humans are the only animals able to build tools. It has since been discovered that chimpanzees often build simple instruments to help retrieve food from holes in the ground, logs, or other hard-to-reach places.
Chimpanzees use a vast array of facial expressions, postures, and gestures to communicate with each other, in addition to at least 32 different sounds. There is some evidence to suggest that chimpanzees are able to learn symbolic languages.
The natural habitat of the chimpanzee is western Africa, from Sierra Leone to the Great Lakes east of the Congo. Living primarily in forested areas, chimpanzees will spend 50 to 70 percent of their time in trees. They are omnivores, eating primarily fruits and vegetables, but they will also hunt and eat small animals. They live in family groups, which consist of about twice as many females as males. While adult chimpanzees are not monogamous, there is a close bond between a young chimp and its parents, and this bond remains unbroken for life. Chimpanzees are very sociable and affectionate animals, and frequently hug, kiss, stroke each other, or hold hands. Violent fights often break out within a social group. The loser of the fight makes up to the winner by displaying submissive behavior and conciliatory gestures. In this way they maintain the social harmony.
Though able to, the chimpanzee rarely walks erect on both feet. Short arm muscles prevent simultaneous extension of the wrists and fingers. Because of this, chimpanzees are unable to walk with their hands flat; when walking on all fours, only the knuckles of their hands touch the ground. Unlike human feet, chimpanzee feet also have an opposing toe, but it is used mainly for climbing and for walking on precarious footing. The foot is rarely used for picking up objects. UNIX and its attendant programs can be unruly beasts. Nutshell Handbooks help you tame them. ... Edie Freedman designed this cover and the entire UNIX bestiary that appears on other Nutshell Handbooks. The beasts themselves are adapted from 19th-century engravings from the Dover Pictorial Archive. The cover layout was produced with Adobe Photoshop 2.5 and Quark XPress 3.3 for the Macintosh, using the Adobe ITC Garamond font.
The inside layout was designed by Edie Freedman and Jennifer Niederst and implemented by Mike Sierra in FrameMaker using Adobe ITC Garamond and New Courier fonts. The figures were created in FrameMaker by Don Libes. The colophon was written by Clairemarie Fisher O'Leary.
