lib/em-ssh/shell.rb
# Wait for a number of seconds until a specified string or regexp is matched by the
# data returned from the ssh connection. Optionally send a given string first.
#
# If a block is not provided the current Fiber will yield until strregex matches or
# :timeout # is reached.
#
# If a block is provided expect will return immediately.
#
# @param [String, Regexp] strregex to match against
# @param [String] send_str the data to send before waiting
# @param [Hash] opts
# @option opts [Fixnum] :timeout (@timeout) number of seconds to wait when there is no activity
# @return [Shell, String] all data received up to an including strregex if a block is not provided.
#                         the Shell if a block is provided
# @example expect a prompt
#   expect(' ~]$ ')
# @example send a command and wait for a prompt
#   expect(' ~]$ ', '/sbin/ifconfig')
# @example expect a prompt and within 5 seconds
#   expect(' ~]$ ', :timeout => 5)
# @example send a command and wait up to 10 seconds for a prompt
#   expect(' ~]$ ', '/etc/sysconfig/openvpn restart', :timeout => 10)
Wait for a number of seconds until a specified string or regexp is matched by the
data returned from the ssh connection. Optionally send a given string first.

If a block is not provided the current Fiber will yield until strregex matches or
:timeout # is reached.

If a block is provided expect will return immediately.
Wait for a number of seconds until a specified string or regexp is matched by the data returned from the ssh connection . Optionally send a given string first . If a block is not provided the current Fiber will yield until strregex matches or : timeout # is reached . If a block is provided expect will return immediately .
def expect(strregex, send_str = nil, opts = {}, &blk)
        assert_channel!
        shell.expect(strregex,
                     send_str,
                     {:timeout => @timeout, :log => self }.merge(opts),
                    &blk)
      end
def expect ( strregex , send_str = nil , opts = { } , & blk ) assert_channel! shell . expect ( strregex , send_str , { :timeout => @timeout , :log => self } . merge ( opts ) , & blk ) end
Wait for a number of seconds until a specified string or regexp is matched by the
data returned from the ssh connection.
Wait for a number of seconds until a specified string or regexp is matched by the data returned from the ssh connection .
all data received up to an including strregex if a block is not provided. the Shell if a block is provided
all data received up to an including strregex if a block is not provided . the Shell if a block is provided
Shell, String
strregex
<not_specific>
send_str
<not_specific>
opts
:timeout (@timeout) number of seconds to wait when there is no activity
: timeout ( @timeout ) number of seconds to wait when there is no activity
blk
<not_specific>
<not_specific>
None
example
expect a prompt expect(' ~]$ ')
expect a prompt expect ( ' ~ ] $ ' )
example
send a command and wait for a prompt expect(' ~]$ ', '/sbin/ifconfig')
send a command and wait for a prompt expect ( ' ~ ] $ ' ' / sbin / ifconfig ' )
example
expect a prompt and within 5 seconds expect(' ~]$ ', :timeout => 5)
expect a prompt and within 5 seconds expect ( ' ~ ] $ ' : timeout = > 5 )
example
send a command and wait up to 10 seconds for a prompt expect(' ~]$ ', '/etc/sysconfig/openvpn restart', :timeout => 10)
send a command and wait up to 10 seconds for a prompt expect ( ' ~ ] $ ' ' / etc / sysconfig / openvpn restart ' : timeout = > 10 )