The—And Other Flags

In Chapter 3 (p. 72), I mentioned the #! line with "" at the end. I did not explain it at the time, but most of the scripts so far have used this line. I described the #! earlier in this chapter. Now I will explain "“. The "" is a flag to Expect. It says not to interpret any of the script arguments but just to pass them on to the script. This is comparable to saying:

expect—script args

Without the "“, Expect itself interprets arguments that look likeflags. Arguments that look like flags begin with a "-" and appear before arguments that do not look like flags. What is important here is that after Expect finds an argument that does not look like a flag, then no other argument can be a flag. I will discuss this more later.

Flags that Expect knows about are:

-b

read the script a line at a time (i.e., unbuffered)

-ccmd

execute this command before any in the script

-ffile

read commands from this file

-d

print internal (diagnostic) information

-D

enable the debugger

−i

run interactively

-n

do not source ∼/.expect.rc

-N

do not source $expect_library/expect.rc

-

read commands from the standard input

do not interpret remaining arguments

Some flags take arguments. These can be run together with the flag itself, but for consistency I always put a space between them. For the sake of accuracy, the term flag includes both the dash, letter, and any arguments.

In the following sections, I will describe each of these flags in detail.

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.