Saturday 27 February 2016

Automate tasks using Expect scripts on Mac OS X

Expect is one of the hidden gems and quite esoteric scripting language for automating tasks on Mac OS X and on most unix flavors.

The idea behind expect is you can program the response to a programmed request string. It's much like a pre-programmed auto-complete feature, in which you have already told the system what the response should be, if it comes across a specific expected request.

Let's try out a basic simple script. In terminal create a new script file : vi expect_test.exp
Note the .exp extension, similar to .sh of bash scripts.

#!/usr/bin/expect

expect "hello"

send "Welcome to IroncladZone \n"

Now if you execute the script ./expect_test.exp and type the string "hello", it will automatically send the response "Welcome to IroncladZone".

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...
eXTReMe Tracker