Exercises, examples and other material relating to training module T242. This topic is presented on public courses Learning to program in Tcl
, Tcl Programming
, Tcl Programming
Expect has a number of advanced facilities like the ability to slow down its output to mimic a human operator more closely, and to be able to handle signals. This module covers these facilities and more.
Related technical and longer articlesThe Typist and the Engineer
|Articles and tips on this subject||updated|
|3448||Checking all the systems on a subnet, using Expect and Tk|
There are times that we want to check the connectivity of all the systems on our subnet - to see which machines are present, and which are not. Pinging them one at a time is a bit slow, but pinging them all at once in a simple script sets up too many connections and the script is likely to fall over. ...
|3009||Expect in Perl - a short explanation and a practical example |
Around 20% of delegates on our Tcl Courses are using Tcl because of the Expect package that extends it to "choreograph" interaction with other systems and processes, and yet the Expect module in Perl (Expect.pm) is decidedly niche and we cover it on our Perl for Larger Projects course only on request. ...
|2475||Quick easy and dangerous - automated logins via Tcl / Expect|
Let me start with a security warning. Passwords and firewalls are there to make it difficult for unauthorized users to get through / at systems, and if you write a script which automates passwords and multi-hop telnet and ssh logins to make it quick and easy for you to get over all the hurdles you are ...
|1531||Expecting a item from a list of possibles|
There are times (and they're quite frequent!) that I'm asked a good question that's so good it's worth sharing the answer. Actually, that makes up a fair proportion of my inspirations for this spot, such as today's.
In Expect - the command line automation tool of the Tcl language - you can tell the ...
|1475||Tcl/Tk - updating your display while tasks are running|
Let me make two statements:
1. When you are popping up a new window from your program, the very last thing you want to see happen is for the window to gradually appear, with bits of it being resized as it comes on the screen - not only is such an operation irritating on the eye, but also it's burning ...
|1411||Buffering of inputs to expect, and match order|
If you're using the expect command to wait for one of a series of inputs within your expect program, information will be checked in the program's internal buffers inthe following order:
a) Any string that matches expect_before will be found
b) Matches to each of the possible patterns in expect in turn
|1173||Cheat Sheet / Check list for Expect maintainers|
Programming in Expect can be very different (and more challenging) than conventional programming. Rather than write code (structured, if you like) through a series of events, you'll do better to start off with a co-operation diagram of the process that you want to automate [[For the newcomer, Expect ...
|435||Expect for Windows|
I've just noticed on the Activestate site that "the ActiveTcl distribution now includes Expect for Windows. A license is no longer required ....". At face value, that looks like excellent news!
One of the big uses of Tcl and Tcl/Tk is in the automation of processes / programs that are designed to ...
Examples from our training material
|chammy|| Automated Logging In|
|engineer|| send_human in expect|
|immortal|| Catching signals in expect|
|multisigs|| Trapping multiple signals in Expect|
|pingabout|| Expect to run ping on a named host; able to switch host during run|
|rupple|| Expect - run rup on a named host|
|sslo|| Send slow example - expect|
|subnet_test|| Check a subnet for pingable systems|
|tcenhance|| Telnet wrapper using interact; provides filtering too|
|tctel|| Telnet wrapper using interact|
|typist|| Second example of expect's "send_human" command.|
PicturesNetwork testing through Expectk
Some modules are available for download
as a sample of our material or under an Open Training Notes License
for free download from http://www.training-notes.co.uk
Topics covered in this module
Expecting from the user.
Using expect and send for user communication.
Waiting for the user or for a process.
Defining default expect patterns.
Command line options.
If you are looking for a complete course and not just a information on a single subject, visit our Listing and schedule
Well House Consultants specialise in training courses in
. We run
throughout the UK (and beyond for longer courses), and
at our training centre in Melksham, Wiltshire, England.
It's surprisingly cost effective to come on our public courses -
even if you live in a different
country or continent to us
We have a technical library of over 700 books on the subjects on which we teach.
These books are available for reference at our training centre. Also
available is the Opentalk
Forum for discussion of technical questions.