Sending To Programs In Cooked Mode
When dealing with programs that run in cooked mode, you must observe certain precautions. In particular, the terminal driver has a big impact on how characters are understood by the program. The terminal driver makes all the translations that it normally does when you are typing by hand. For instance, the return character is translated to a \n, and the line kill character (typically ^U) removes all the characters typed so far in the current line.
Some characters generate signals. For instance, ^C and ^Z are usually tied to signals that interrupt and suspend a process. For example, in cooked mode a process never reads a ^Z. Rather, the terminal driver turns it into a signal which stops the process. When sending a ^Z by hand, control returns to a shell automatically. However, if the process was created directly by spawn, there is no shell to which to return, so once the process stops, it will not say "suspended" or anything else. The process is really stopped and will remain so until it receives a continue signal. Unless you are explicitly testing how a process reacts to a signal, there is no point in sending it characters like these. (Expect does not need to suspend processes anyway. To do job control, Expect scripts merely change spawn_id or use an −i flag.)
Another problem that arises in cooked mode is limitations in the device driver itself. For instance, you must avoid sending “too many” characters in a row without a return. Most UNIX systems ...