From: Robert Klemme Date: 2013-03-19T16:34:03+09:00 Subject: Re: Cisco Ruby pexpect equivalent On Tue, Mar 19, 2013 at 1:14 AM, Steve Jarvis 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 `
' irb(main):002:0> require 'expect' => true irb(main):003:0> IO.instance_method :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/