Project

expectr

0.01
No commit activity in last 3 years
No release in over 3 years
Expectr is an interface to the functionality of Expect in Ruby
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies
 Project Readme

Expectr¶ ↑

Expectr is an API to the functionality of Expect (see expect.nist.gov/) implemented in ruby.

Using Expectr¶ ↑

Effort is taken to make implementation as simple as possible.

Automation¶ ↑

Implementation of task automation should be relatively straightforward. A lightweight application might look similar to the following:

# myapp.rb
require 'expectr'

exp = Expectr.new( '/bin/bash', flush_buffer: false )
exp.send( "ls\n" )
match = exp.expect( %r{bash} ) # => MatchData
match = exp.expect( "this shouldn't match anything" ) # raises Timeout::Error

Interaction¶ ↑

It is possible to allow a user to interact directly with an Expectr object as with the Expect functionality in TCL

# logmein.rb
require 'expectr'

ssh = { host: 'example.com', user: 'example', pass: 'password' }
exp = Expectr.new( "ssh #{ssh[:user]}@#{ssh[:host]}" )
exp.expect( %r{#{ssh[:user]}@#{ssh[:host]}'s password:} )
ssh.send( ssh[:pass] + "\n" )

ssh.interact!

Contributions¶ ↑

Effort is made to keep external requirements to a minimum. As such, presently there are no external requirements for development. If you want to contribute, please:

* Fork the project.
* Make a branch for your contribution if it's more than a simple fix.
* Add tests for new functionality.
* Send me a pull request on Github

Copyright © 2012-2015 Tina Wuest. See LICENSE for details.