bash expect: script to handle command line prompts

expect is very useful to automate login process. I thought it is helpful when doing testing as well. A simple login script might work like this:

#!/usr/bin/env expect
eval spawn "/path/program"
expect "^Enter Auth Username:"
send "user\n"
expect "Enter Auth Password:"
send "password\n" 

To install expect, “yum install expect”

Author: bpeh

Bernard Peh is a great passioner of web technologies and one of the co-founder of Sitecritic.net Website Design and Reviews. He works with experienced web designers and developers everyday, developing and designing commercial websites. He specialises mainly in SEO and PHP programming.