The -b Flag

The -b flag forces the script file to be read one line at a time (i.e., unbuffered). This is not normally necessary, but could be useful if the script file has not been completely written by the time Expect begins executing it. In general, however, it is simpler just to feed commands to the standard input of Expect (see next section). This avoids the necessity of a temporary script file.

By default (i.e., without the -b flag), the entire script is read into memory before being executed. A benefit of this is that you can edit scripts while executing them, and you do not have to worry about Expect (or a user) getting confused by the script changing out from under them.

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.