class
SSH2::Channel
- SSH2::Channel
- IO
- Reference
- Object
Defined in:
channel.crConstant Summary
-
PROCESS_EXEC =
"exec" -
PROCESS_SHELL =
"shell" -
PROCESS_SUBSYSTEM =
"subsystem"
Constructors
Instance Method Summary
-
#close(wait = false)
Close an active data channel.
-
#closed? : Bool
Returns
trueif thisIOis closed. -
#command(command)
Start a specified command
-
#eof?
Check if the remote host has sent an EOF status for the selected stream.
-
#err_stream
Returns the channel's stderr substream as its own
IO(StreamIO). -
#exit_signal
Return a tuple with first field populated with the exit signal (without leading "SIG"), and the second field populated with the error message.
-
#exit_status
Returns the exit code raised by the process running on the remote host at the other end of the named channel.
- #finalize
-
#flush(stream_id = 0)
Flush channel
-
#flush_all
Flush all substreams
-
#flush_extended_data
Flush all extended data substreams
-
#flush_stderr
Flush stderr
-
#handle_extended_data(ignore_mode : LibSSH2::ExtendedData)
LibSSH2::ExtendedData::NORMAL - Queue extended data for eventual reading LibSSH2::ExtendedData::MERGE - Treat extended data and ordinary data the same.
-
#process_startup(request, message)
Request a process on the channel.
-
#read(stream_id, slice : Slice(UInt8))
Read up to
slice.bytesizebytes from substreamstream_idintoslice, returning the number of bytes read. -
#read(slice : Slice(UInt8)) : Int32
IO#read: reads from the main (stdout) substream intoslice, returning the number of bytes read, or0at end-of-file. -
#read_stderr(slice : Slice(UInt8))
Read from the channel's stderr substream into
slice. -
#receive_window_adjust(adjustment, force = false)
Adjust the receive window for a channel by adjustment bytes.
-
#request_pty(term, modes : Array(Tuple(TerminalMode, UInt32)) | Nil = nil, width = LibSSH2::TERM_WIDTH, height = LibSSH2::TERM_HEIGHT, width_px = LibSSH2::TERM_WIDTH_PX, height_px = LibSSH2::TERM_HEIGHT_PX)
Request a PTY on an established channel.
-
#send_eof(wait = false)
Tell the remote host that no further data will be sent on the specified channel.
- #session : Session
-
#setenv(varname, value)
Set an environment variable in the remote channel's process space.
-
#shell
Start shell
- #socket
-
#stream(stream_id)
Returns substream
stream_idas its ownIO(StreamIO). -
#subsystem(subsystem)
Start a specified subsystem
- #to_unsafe : Pointer(Void)
-
#wait_closed
Wait for the remote end to acknowledge the channel close.
-
#wait_eof
Wait for the remote end to acknowledge an EOF request.
-
#window_read
The number of bytes which the remote end may send without overflowing the window limit
-
#window_write
Check the status of the write window Returns the number of bytes which may be safely written on the channel without blocking.
-
#write(stream_id, slice : Slice(UInt8))
Write all of
sliceto substreamstream_id, returning the number of bytes written. -
#write(slice : Bytes) : Nil
Writes the contents of slice into this
IO. -
#write_stderr(slice : Slice(UInt8))
Write
sliceto the channel's stderr substream.
Constructor Detail
Instance Method Detail
Close an active data channel. In practice this means sending an
SSH_MSG_CLOSE packet to the remote host which serves as instruction that no
further data will be sent to it. The remote host may still send data back
until it sends its own close message in response. To wait for the remote
end to close its connection as well, follow this command with
#wait_closed or pass wait parameter as true.
Returns true if this IO is closed.
IO defines returns false, but including types may override.
Return a tuple with first field populated with the exit signal (without leading "SIG"), and the second field populated with the error message.
Returns the exit code raised by the process running on the remote host at the other end of the named channel. Note that the exit status may not be available if the remote end has not yet set its status to closed.
LibSSH2::ExtendedData::NORMAL - Queue extended data for eventual reading
LibSSH2::ExtendedData::MERGE - Treat extended data and ordinary data the
same. Merge all substreams such that calls to #read, will pull from all
substreams on a first-in/first-out basis.
LibSSH2::ExtendedData::IGNORE - Discard all extended data as it arrives.
Request a process on the channel. request is one of PROCESS_SHELL,
PROCESS_EXEC or PROCESS_SUBSYSTEM; prefer #shell, #command or #subsystem.
Read up to slice.bytesize bytes from substream stream_id into slice,
returning the number of bytes read.
IO#read: reads from the main (stdout) substream into slice, returning the
number of bytes read, or 0 at end-of-file.
Adjust the receive window for a channel by adjustment bytes. If the amount
to be adjusted is less than LibSSH2::CHANNEL_MINADJUST and force is false the
adjustment amount will be queued for a later packet.
Returns a new size of the receive window (as understood by remote end).
Request a PTY on an established channel. Note that this does not make sense for all channel types and may be ignored by the server despite returning success.
Tell the remote host that no further data will be sent on the specified channel. Processes typically interpret this as a closed stdin descriptor.
Set an environment variable in the remote channel's process space. Note that this does not make sense for all channel types and may be ignored by the server despite returning success.
The number of bytes which the remote end may send without overflowing the window limit
Check the status of the write window Returns the number of bytes which may be safely written on the channel without blocking.
Write all of slice to substream stream_id, returning the number of bytes
written.
channel_write can write less than we asked. loop until slice is done. n == 0 is allowed by libssh2 (buffered, not acked). yield so we don't spin.
Writes the contents of slice into this IO.
io = IO::Memory.new
slice = Bytes.new(4) { |i| ('a'.ord + i).to_u8 }
io.write(slice)
io.to_s # => "abcd"