Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))

Well House Consultants
You are on the site of Well House Consultants who provide Open Source Training Courses and business hotel accommodation. You are welcome to browse and use our resources subject to our copyright statement and to add in links from your pages to ours.
Other subject areas - resources
Java Resources
Well House Manor Resources
Perl Resources
Python Resources
PHP Resources
Object Orientation and General topics
MySQL Resources
Linux / LAMP / Tomcat Resources
Well House Consultants Resources
Extras Resources
C and C++ Resources
Ruby Resources
Tcl/Tk Resources
Web and Intranet Resources
Tcl/Tk module T211
What is Expect? Why use it?
Exercises, examples and other material relating to training module T211. This topic is presented on public courses Learning to program in Tcl, Tcl Programming, Tcl Programming

Expect is a Tcl extension that's heavily used by perhaps a third of our trainees. If you have an application that's designed for a human user, but you want to run it automatically, expect lets you mimic the human actions via a series of send and expect commands.

Related technical and longer articles
A Web interface for your Linux admin tasks

Articles and tips on this subjectupdated
4678Expect with Ruby - a training example to get you started
The Expect library, originally written for use wth Tcl, is also available in other languages and today I wrote an example to introduce how it's used in Ruby. Please note this is a spike solution - not going to fail (if it does) in a pretty way. The principle of expect is that you spawn a process - ...
4405Backup procedures - via backup server
Our main web server system becomes ever more important to our business - and having procedures in place to restore systems in the event of failure becomes ever more critical. What are we protecting against? Both hardware and software failures, and against intrusions and obsolescence (to the extent of ...
3572Adding Expect on top of Tcl - what is it and where can I get a training course to learn about it?
Expect adds extra commands on top of Tcl - allowing the Tcl programmer to control additional processes as is they were really being run from the command line. But because they're being run from within a program, a whole lot of commands can be run with little effort, responses analysed easily, with the ...
3286Should we cover expect and/or Tk on our public Tcl courses?
A sizeable minority of our Tcl course delegates use the expect and / or tk extensions. And on our Tcl courses we handle the two differently. For Expect, we include some coverage in our standard agenda, running if required an hour or two into the evening of starting early in the morning to ensure substantial ...
2489Parallel Pinging, using Python Threads or Expect spawn lists
Ping is a very useful command to use within scripts for checking the presence (or absence) of a live system on our network, or indeed on the Internet. However, there are subtle differences in the format of its report on different operating system flavors, so any code that you write that needs to analyse ...
3009Expect 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. ...
2474Using Tcl and Expect to automate repetitive jobs
If you're typing the same series of instructions into your computer time and time again, perhaps with predictable variations depending on the responses that you get, you should consider using Expect. Expect adds three extra major commands to the Tcl language: • spawn to start a process • send ...
1602Automating processes through Expect
What is Expect? Let me give you an example of how it's used to help answer that question. I want to connect to a remote host that I can access through FTP, and have a look at all the files with "top", "sql" and "txt" in their names in my home directory. And that's something I need to do on a regular ...
1531Expecting 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 ...
1469Curley brackets v double quotes - Tcl, Tk, Expect
In Tcl, both Curley braces and double quotes can be used to hold a block of program or data together as a single unit / parameter ... but there are differences ... a) Curley braces can stretch over a number of lines, with new lines within the block being simply a part of the block. So they're ideal ...
1411Buffering 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 c) ...
1409What is Expect?
Expect is an extension to the Tcl language which provides three key new commands - spawn which lets you start up another process, send which lets you send information to that process and expect through which you can receive back responses from that process. For the majority of users of Tcl, Expect is ...
1174Installing Tcl and Expect on Solaris 10 - a checklist
Hot off the presses from the last couple of days - a check list (and a couple of "Gotcha" notes) concerning the installation of Tcl and Expect on a Solaris 10 system, compiling from scratch were possible. You'll need a C Compiler We used gcc (the Gnu C compiler) and we installed it from Sun standard ...
1173Cheat 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 ...
286Automating regular manual procedures
Do you want to automate a process that you normally run manually? If the process runs from a terminal window (or can be, even if you normally use a GUI), then have a look at Expect. With Expect, you spawn the process you want to automate, then programatically send inputs to it and expect responses. ...
Examples from our training material
e1   Simplest ping check via expect
e2   Ping via expect, echo back a value from the report
e3   expect - do not grab indeterminate
evening   Automated backup
ftp1   First Expect example
ftp2   Expect with some error checking and decisions
gup   Grabbing a log file and locally analysing
linksandimages   Grab a web page, report all links and images
plet.exp   Expect for Windows - ping a host and guess its distance from you
qp   Expect to automate a series of pings
weblinks   Grab a web page and report all links
wuff   Expecting from a list (regular expression)
xpx   quick ping around a series of hosts
yap   Expecting from a list (expect block)
Tcl and Expect - a great way to handle interaction
Background information
Some modules are available for download as a sample of our material or under an Open Training Notes License for free download from [here].
Topics covered in this module
Sample problems.
A regular task.
A solution.
Software testing.
A possible solution.
What else is Expect?.
Expect commands.
spawn, expect and send.
More on the expect command.
Not wanting to echo what you expected?.
Not knowing what to expect?.
Variables set by expect.
Expect patterns.
Running Expect on Windows platforms.
Complete learning
If you are looking for a complete course and not just a information on a single subject, visit our Listing and schedule page.

Well House Consultants specialise in training courses in Tcl/Tk, Expect,Ruby, Lua, Python, Perl, PHP, and MySQL. We run Private Courses throughout the UK (and beyond for longer courses), and Public Courses 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.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2024: 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/resources/T211.html • PAGE BUILT: Sun Oct 11 14:50:09 2020 • BUILD SYSTEM: JelliaJamb