Huh. I use something like this....

This is an extremely old script of mine but still does the job.

require 'rubygems'
>
> require 'net/ssh'
>
> require 'net/ssh/telnet'
>
>
>> class SSH
>
>   attr_accessor :errors
>
>
>
>   def initialize(creds)
>
>     begin
>
>       @ssh_session = Net::SSH.start(creds[:host], creds[:user], :password
>> => creds[:password], :keys => [])
>
>       @ssh = Net::SSH::Telnet.new("Session" => @ssh_session, "Prompt" =>
>> creds[:prompt])
>
>       @errors = false
>
>     rescue Exception => e
>
>       @errors = e
>
>     end
>
>   end
>
>
>
>   def cmd(command)
>
>     @ssh.cmd(command)
>
>   end
>
>
>
>   def close
>
>     @ssh.close
>
>   end
>
>
>
> end
>
>
>

I then wrap it for different devices like F5 LTM or Cisco IOS.

creds[:prompt] = /.*>|.*#/
ssh.cmd("en\r#{creds[:enable]}")
ssh.cmd("term len 0")
config = @ssh.cmd("show run")

But if you browse github there are even more elaborate things people have
built out there for device automation/interaction. I don't know if you need
pexpect but i am not that familiar with it. As a Sr Neteng I can tell you
I've never used it and I'm an automation loon!



On Tue, Mar 19, 2013 at 12:34 AM, Robert Klemme
<shortcutter / googlemail.com>wrote:

> On Tue, Mar 19, 2013 at 1:14 AM, Steve Jarvis <lists / ruby-forum.com>
> wrote:
> > Hi All,
> >
> > This is my first post (long time lurker)
> >
> > Is anyone aware of a compatible library to python's "pexpect"?
>
> Does that something like Ruby's IO#expect?
>
> irb(main):001:0> IO.instance_method :expect
> NameError: undefined method `expect' for class `IO'
>         from (irb):1:in `instance_method'
>         from (irb):1
>         from /usr/bin/irb:12:in `<main>'
> irb(main):002:0> require 'expect'
> => true
> irb(main):003:0> IO.instance_method :expect
> => #<UnboundMethod: IO#expect>
>
> $ ri -T IO#expect
> IO#expect
>
> (from ruby core)
>
> ------------------------------------------------------------------------------
>   expect(pat,timeout=9999999) { |result| ... }
>
>
> ------------------------------------------------------------------------------
>
> Reads from the IO until pattern pat matches or the timeout is
> over. It returns an array with the read buffer, followed by the matches.
> If a
> block is given, the result is yielded to the block and returns nil.
>
> The optional timeout parameter defines, in seconds, the total time to wait
> for
> the pattern.  If the timeout expires or eof is found, nil is returned or
> yielded.  However, the buffer in a timeout session is kept for the next
> expect
> call.  The default timeout is 9999999 seconds.
>
>
> Kind regards
>
> robert
>
> --
> remember.guy do |as, often| as.you_can - without end
> http://blog.rubybestpractices.com/
>
>


-- 
vizualize.me/cliffrosson