The -n And -N Flags

By default, Expect reads and evaluates the commands in two files when it starts. It does this whether you run Expect interactively or from a script. Generically, the files are called dot rc files.

The first file Expect reads is expect.rc in the directory $expect_library. The variable expect_library is predefined by the person who installed Expect on your computer. It contains a directory for common Expect scripts and fragments that can be used from other scripts.

The file expect.rc can be used to customize Expect on a particular computer without changing the binary. This is very useful if Expect is shared among many computers because it is on a common file system. Rather than having multiple different copies of Expect, each host can modify expect.rc—presumably a very short file.

Next, the file .expect.rc is read. Expect looks for .expect.rc in the directory specified by the environment variables DOTDIR or HOME in that order. The .expect.rc file can be used to customize Expect on a personal basis. This would, for example, be an appropriate way to define your own personal prompts for Expect to use when it is interactively prompting for commands. Changing the prompt is shown in more detail on page 223.

Another common use for .expect.rc is to configure Expect applications that use the Tk extension to control the X Window System. For example, the tk_strictMotif flag can be used to disable Tk’s default behavior of automatically highlighting buttons as the cursor crosses ...

Get Exploring Expect now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.