Exercises
Modify the Dvorak keyboard script (page 325) to so that it uses a single
sendcommand. Use an array to provide the mapping between input and output. Can you tell any difference in speed between the two implementations?On page 330, I showed a script that responded to an inactivity message. However, some systems do not print a warning message. Rewrite the script so that it does not require a warning message. Experiment with resetting the timer by sending a null or a ^Q or a space-delete sequence.
Modify the
scriptscript (on page 334) so that it strips out carriage returns. Does "stty -ocrnl" help? How about "tr -d '\015'“?Write a script to boot and simultaneously allow interaction with an auxiliary processor such as a vxWorks board. Make the script respond appropriately if the board hangs for more than one minute or if the board is power-cycled behind Expect’s back.
Write a script that allows you to repeat a command in the shell (or any program) by pressing a single function-key. Write a second version that suspends this behavior when the shell is not prompting.
Write a script that provides “hotkey” service in the style of a DOS TSR, which will temporarily bring a background process to the foreground. Allow triggering either by keypresses or specific times.