Class: Net::SSH::Service::Process::OpenManager

Class | Net::SSH::Service::Process::OpenManager
In: | lib/net/ssh/service/process/open.rb
Parent: | Object

A delegate class to manage the processing for a single executed process on the remote host. It opens a channel, executes the process on it, and manages the various callbacks.

This service is typically used like this:

      Net::SSH.start( 'host', 'user' ) do |session|
        session.process.open( "bc" ) do |process|
          ...
        end
      end

### Methods

close close_input do_close do_confirm do_data do_exec_failure do_exec_success do_extended_data do_request new on_exit on_failure on_stderr on_stdout on_success puts write

### Public Class methods

new( connection, log, command ) {|self| ...}

Create a new OpenManager instance on the given connection. It will attempt to execute the given command. If a block is given, the manager will be yielded to the block, and the constructor will not return until all channels are closed.

### Public Instance methods

close()

Close the process. All streams (`stdin`, `stdout`, `stderr`) will be closed. Any output that the process had already produced will still be sent, but it will be shut down as soon as possible. This will return immediately.

close_input()

Indicate that no more data will be sent to the process (sends an EOF to the process). The process may continue to send data, but the `stdin` stream is effectively closed. This will return immediately.

do_close( channel )

Invoked when the channel is closed. This simply delegates to the `on_exit` callback, if registered.

do_confirm( channel )

Invoked when the channel‘s opening has been confirmed by the server. This is where the command to execute will be sent to the server.

do_data( channel, data )

Invoked when data arrives over the channel. This simply delegates to the `on_stdout` callback, if registered.

do_exec_failure( channel )

Invoked when the invocation of the command failed. This will call the `on_failure` callback, if registered, or will otherwise raise an exception.

do_exec_success( channel )

Invoked when the invocation of the command has been successful. This registers various callbacks, and then calls the `on_success` callback (if registered).

do_extended_data( channel, type, data )

Invoked when extended data arrives over the channel. This simply delegates to the `on_stderr` callback, if registered, if the type is 1; otherwise it does nothing.

do_request( channel, type, want_reply, data )

Invoked when a channel request is received.

on_exit( &block )

Register the given block to be invoked when the process terminates normally. The block should accept two parameters: the process instance (`self`) and the exit status of the process.

on_failure( &block )

Register the given block to be invoked when the command could not be started. The block should accept two parameters: the process instance (`self`) and a status string. (The status string is currently always `nil`, since SSH itself does not indicate why the program failed to start.)

on_stderr( &block )

Register the given block to be invoked when data is recieved from the invoked command‘s `stderr` stream. The block should accept two parameters: the process instance (`self`) and the data string. Note that if the process sends large amounts of data, this method may be invoked multiple times, each time with a portion of the command‘s error output.

on_stdout( &block )

Register the given block to be invoked when data is recieved from the invoked command‘s `stdout` stream. The block should accept two parameters: the process instance (`self`) and the data string. Note that if the process sends large amounts of data, this method may be invoked multiple times, each time with a portion of the command‘s output.

on_success( &block )

Register the given block to be invoked when the command has been confirmed to have been successfully started. The block should accept a single parameter, the process instance that was created (`self`).

puts( data )

Send the given data to the process, appending a newline. As with Kernel::puts, this will not append a newline if the string already has one. See write.

write( data )

Send the given data to the process. It will be sent via the process‘s `stdin` stream. This method returns immediately.

[Validate]