Sending Nulls

In Chapter 6 (p. 153), I described how to detect a null character. A null can be sent by calling send with the -null flag. By default, one null is sent to the currently spawned process.

send -null

An optional integer may be used to send several nulls. For example, the following command sends three nulls.

send -null 3

send uses the pattern "-null" while expect uses "null“. The absence of a hyphen is historical—all of the special patterns lack a hyphen.

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.