Is still worth learning expect? Because I have not seen any new books on this topic? What would anyone recommend for a good book on this?
To stop recording keystrokes to your script, press Ctrl+D on your keyboard to stop Autoexpect and copy the buffer to your file.
The final command " expect eof " causes the script to wait for the end-of-file in the output of passwd . Similar to timeout , eof is another keyword pattern. This final expect effectively waits for passwd to complete execution before returning control to the script.
New! Save questions or answers and organize your favorite content. Learn more.
Expect scripts can be used to automate multiple CLI commands in batch mode. Expect is a UNIX scripting and testing utility which can be used with SSH-based applications, like the Oracle VM CLI. Expect scripts can have any file name suffix you like, though they generally have an .exp extension.
expect is best used for controlling scripts that output queries and require a response. Many other languages struggle with this and create deadlocks on stdin/stdout when trying to use both. Expect also overcomes some issues with password entry (like when scripting SSH).
Having said that it isn't necessary to know expect because many other languages have an expect module (tcl and python come to mind) which provide the same behaviour.
I would have to say it depends on your job. If you spend a lot of time interacting with repetitive commandline scripts or FTP then expect is well worth adding to your scripting arsenal.
SpliFF wrote above about "... interacting with repetitive commandline script or FTP ..." While I'm all for automation, and regard Expect as indispensable, Expect is NOT necessary in 2010 for FTP or many other roles where it once was necessary. Fifteen years ago, for example, Expect was an appropriate way to automate FTP; now, most scripting languages already build in capabilities sufficient to replace Expect's use with FTP. Many, many automations can be done with what Perl, Python, Tcl, ... already build in, and Expect is not essential for these applications.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With