Expect – A tool for automating interactive applications
expect.sourceforge.net
Expect – A tool for automating interactive applications
1–10 of 52 posts
Re: Expect – A tool for automating interactive applications
#2I remember this from writing chat(8) scripts. Pretty nice little language!
Re: Expect – A tool for automating interactive applications
#3I remember seeing an elisp equivalent used to write ftp clients in emacs. Can't find it again, but anyway, I never got to see the original expect.
Re: Expect – A tool for automating interactive applications
#4I used to use expect to automate a bunch of business reports and system functions. I switched to a python work-alike called pexpect that I still use and love. It feels a little hacky but it works and saves a huge amount of time over the course of a year.
Re: Expect – A tool for automating interactive applications
#5I use it to install MySQL with some non default values. I'm not that good with bash and install scripts and expect was the only way around some issues I was having.
secure_mysql_script=$(expect -c '
spawn sudo mysql_secure_installation
expect "Enter current password for root (enter for none):"
send "\r"
expect "Change the root password?"
send "n\r"
expect "Remove anonymous users?"
send "y\r"
expect "Disallow root login remotely?"
send "y\r"
expect "Remove test database and access to it?"
send "y\r"
expect "Reload privilege tables now?"
send "y\r"
expect eof
')
echo "$secure_mysql_script"Re: Expect – A tool for automating interactive applications
#6It's wonderful for rapidly SSHing into a bunch of machines for doing automated things.
It's a fast hacking provisioning tool, I really like it for this purpose.
Re: Expect – A tool for automating interactive applications
#7Be sure to check out "autoexpect": it starts an interactive session, and generates an expect script based on that. Then you typically need to edit it for generalization (e.g., skip dates and time strings; often skip version strings, etc.).
Re: Expect – A tool for automating interactive applications
#8I have been using a Ruby expect-like called Greenletters by Avdi Grimm, introduced on his blog here: http://devblog.avdi.org/2010/07/19/greenletters-painless-aut...
It's available via rubygems or github: https://github.com/avdi/greenletters
Re: Expect – A tool for automating interactive applications
#9expect is one of the most useful system administration tools out there! I've used it to batch-modify settings on 100 machines where I couldn't just scp in a new file due to each one needing small variations.
If you don't know expect (and you're a sysadmin), learn it.
Re: Expect – A tool for automating interactive applications
#10I love expect. We use it in upstart scripts. Little known gem of the unix world.