May 2017
Beginner
552 pages
28h 47m
English
expect does not come by default on all Linux distributions. You may have to install the expect package with your package manager (apt-get or yum).
Expect has three main commands:
|
Commands
|
Description
|
| spawn | Runs the new target application. |
| expect | Watches for a pattern to be sent by the target application. |
| send | Sends a string to the target application. |
The following example spawns the backup script and then looks for the patterns *folder* and *file* to determine if the backup script is asking for a folder name or a filename. It will then send the appropriate reply. If the backup script is rewritten to request files first and then folders, this automation script still works.
#!/usr/bin/expect #Filename: ...