Upgrade to Pro — share decks privately, control downloads, hide ads and more …

The venerable "expect"

The venerable "expect"

Expect tool fundamentals. Accompanying code: https://gist.github.com/bruno-/dc4255f6d426af00c240

Ee1bd63b4d7f6e79bdcddf1611ccec99?s=128

Bruno Sutic

January 29, 2015
Tweet

Transcript

  1. The venerable “expect”

  2. About: Bruno Sutic, github.com/bruno-/
 Rails & Javascript developer
 Ideal Project

    Group, Chicago
  3. What is expect? • a classic Unix tool • enables

    automating *everything* in the terminal • written in 1990, Tcl
  4. Can’t script everything • ssh password entry? • sudo password

    entry? • doing multiple ssh “hops”, usually password protected
 (enterprises, telecoms) • interactive command line applications (tmux) • (short demo)
  5. Expect is… • surprisingly easy to learn • powerful •

    easily available (installed by default on OS X) • does not replace scripting, use it for small % of tasks
  6. Demo
 automating ssh tasks

  7. Commands summary • spawn - starts a program • expect

    - “listens” for output • send - “types” program input • interact - gives control to the user
  8. Commands summary • log_user 0 - make the script quiet

    • puts - print to the screen • set timeout 10
 …
 timeout { exit 1 }
  9. My real-world usage examples • Ericsson NT - automating SSH

    connections (3-4 hops) • Automated testing for tmux plugins • tmux plugin manager • tmux copycat
  10. Questions?