A service class for interacting with a user‘s shell on a remote machine. The shell may be interacted with either with or without a pty.

Methods
Public Class methods
new( connection, log, pty_opts )

Create a new shell over the given connection. The pty_opts parameter must be either a Hash of the allowed values for the Net::SSH::Connection::Channel#request_pty method, or a boolean value (indicating whether a pty should be allocated or not). This will block until the shell is open and ready to receive input.

    # File lib/net/ssh/service/shell/shell.rb, line 37
37:           def initialize( connection, log, pty_opts )
38:             @connection = connection
39:             @log = log
40: 
41:             @pty_opts = pty_opts
42: 
43:             @stdout = ""
44:             @stderr = ""
45: 
46:             @state = :opening
47:             @connection.open_channel( "session", &method( :on_confirm ) )
48: 
49:             @connection.loop { @state != :open && @state != :closed }
50:             raise "could not open shell" if @state != :open
51:           end
Public Instance methods
method_missing( sym, *args )

Reinterprets method invocations as requests to send data to the shell. The method name and the arguments are concatenated together with spaces and a newline appended. The resulting string is sent to the shell via send_data.

     # File lib/net/ssh/service/shell/shell.rb, line 113
113:           def method_missing( sym, *args )
114:             cmd = sym.to_s
115:             cmd << " " << args.join( " " ) unless args.empty?
116:             send_data cmd + "\n"
117:           end
open?()

Returns true if the shell is open.

    # File lib/net/ssh/service/shell/shell.rb, line 54
54:           def open?
55:             @state == :open
56:           end
send_data( data )

Sends the given data to the shell on the shell‘s stdin stream.

     # File lib/net/ssh/service/shell/shell.rb, line 97
 97:           def send_data( data )
 98:             raise "channel not open" unless @state == :open
 99:             @channel.send_data data
100:           end
send_extended_data( type, data )

Sends the given data to the shell on the stream indicated by the type parameter.

     # File lib/net/ssh/service/shell/shell.rb, line 104
104:           def send_extended_data( type, data )
105:             raise "channel not open" unless @state == :open
106:             @channel.send_extended_data type, data
107:           end
stderr()

Return the stderr output (if any) that the shell has generated since the last time this method was invoked.

    # File lib/net/ssh/service/shell/shell.rb, line 79
79:           def stderr
80:             string, @stderr = @stderr, ""
81:             string
82:           end
stderr?()

Returns true if there is any data from the shell on stderr, consuming input on the connection in a non-blocking manner to make sure that any available data is considered.

    # File lib/net/ssh/service/shell/shell.rb, line 87
87:           def stderr?
88:             exists = @stderr.length > 0
89:             unless exists
90:               consume_connection
91:               exists = @stderr.length > 0
92:             end
93:             exists
94:           end
stdout()

Return the stdout output (if any) that the shell has generated since the last time this method was invoked.

    # File lib/net/ssh/service/shell/shell.rb, line 60
60:           def stdout
61:             string, @stdout = @stdout, ""
62:             string
63:           end
stdout?()

Returns true if there is any data from the shell on stdout, consuming input on the connection in a non-blocking manner to make sure that any available data is considered.

    # File lib/net/ssh/service/shell/shell.rb, line 68
68:           def stdout?
69:             exists = @stdout.length > 0
70:             unless exists
71:               consume_connection
72:               exists = @stdout.length > 0
73:             end
74:             exists
75:           end