sshkit v0.0.1 SSHKit.SSH.Channel
Summary
Functions
Closes an SSH channel
Sends an EOF message on an open SSH channel
Executes a command on the remote host
Loops over channel messages until the channel is closed
Opens a channel on an SSH connection
Receive the next message on an open SSH channel
Sends data across an open SSH channel
Functions
Closes an SSH channel.
Returns :ok.
For more details, see :ssh_connection.close/2.
Sends an EOF message on an open SSH channel.
Returns :ok or {:error, :closed}.
For more details, see :ssh_connection.send_eof/2.
Executes a command on the remote host.
Returns :success, :failure or {:error, reason}.
For more details, see :ssh_connection.exec/4.
Processing channel messages
loop/4 may be used to process any channel messages received as a result of
executing command on the remote.
Loops over channel messages until the channel is closed.
Invokes fun for each channel message, passing the channel, message and
state as arguments. fun’s return value is stored in state.
timeout specifies the maximum delay between two subsequent messages.
Returns state after the channel is closed, or {:error, :timeout}.
Opens a channel on an SSH connection.
On success, returns {:ok, channel}, where channel is a Channel struct.
Returns {:error, reason} if a failure occurs.
For more details, see :ssh_connection.session_channel/4.
Options
:type- the type of the channel, defaults to:session:timeout- defaults to:infinity:initial_window_size- defaults to 128 KiB:max_packet_size- defaults to 32 KiB
Receive the next message on an open SSH channel.
Returns {:ok, message} or {:error, :timeout}.
For more details, see :ssh_connection.
Messages
The message tuples returned by recv/3 correspond to the underlying Erlang
channel messages with the channel id stripped. recv only listens to
messages from the channel specified as the first argument.
{:data, type, data}- data has arrived,typeis 0 “normal” or 1 “stderr”{:eof}- indicates that no more data is to be sent by the remote process{:exit_signal, signal, msg, lang}- remote execution terminated bysignal{:exit_status, status}- remote command terminated with exit codestatus{:closed}- indicates that the channel has now been shut down
Sends data across an open SSH channel.
Returns :ok, {:error, :timeout} or {:error, :closed}.
For more details, see :ssh_connection.send/5.