Exercises

  1. Parameterize the send_slow script on page 273.

  2. Write a script which runs a shell such that all of the output written to the standard output and standard error is written humanly.

  3. Write a procedure that takes a 32-bit integer and sends it encoded as four bytes, each byte representing 8 bits worth. It should be analogous to the procedure expect_four_byte_int in Chapter 6 (p. 154).

  4. Run the script on page 271 to find out the size of your system’s canonical input buffer. Modify it if necessary to account for your system’s behavior when the limit is reached. Is this behavior documented anywhere? Is the limit documented anywhere? Try the script on other system types.

  5. Write statements that simulate the sending of the Up, Down, Left, and Right arrow keys on your keyboard.

  6. Solve the previous exercise in a terminal-independent way by using information from the termcap file or terminfo database.

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.