Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Expect Scripts Still Worth Learning? [closed]

Tags:

expect

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?

like image 325
Carmen Avatar asked Sep 03 '10 03:09

Carmen


People also ask

How do I turn off Autoexpect?

To stop recording keystrokes to your script, press Ctrl+D on your keyboard to stop Autoexpect and copy the buffer to your file.

What does expect EOF do?

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.

Can I use expect in bash script?

New! Save questions or answers and organize your favorite content. Learn more.

What are expect scripts?

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.


2 Answers

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.

like image 90
SpliFF Avatar answered Sep 27 '22 16:09

SpliFF


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.

like image 41
Cameron Laird Avatar answered Sep 27 '22 16:09

Cameron Laird