Liking cljdoc? Tell your friends :D

clj-libssh2.channel

Functions for manipulating channels within an SSH session.

Functions for manipulating channels within an SSH session.
raw docstring

closeclj

(close session channel)

Close a channel.

Arguments:

session The clj-libssh2.session.Session object for the current session. channel The channel to close.

Return:

0 on success. An exception will be thrown if an error occurs.

Close a channel.

Arguments:

session  The clj-libssh2.session.Session object for the current session.
channel  The channel to close.

Return:

0 on success. An exception will be thrown if an error occurs.
sourceraw docstring

execclj

(exec session channel commandline)

Execute a command on the remote host. This merely starts the execution of the command. The input(s), output(s) and exit status of the command must be handled separately.

Arguments:

session The clj-libssh2.session.Session object for the current session. channel Execute the command via this channel. commandline The command to execute on the remote host.

Return:

0 on success. An exception will be thrown if an error occurs.

Execute a command on the remote host. This merely starts the execution of
the command. The input(s), output(s) and exit status of the command must be
handled separately.

Arguments:

session      The clj-libssh2.session.Session object for the current session.
channel      Execute the command via this channel.
commandline  The command to execute on the remote host.

Return:

0 on success. An exception will be thrown if an error occurs.
sourceraw docstring

exit-signalclj

(exit-signal session channel)

Collect the exit signal data from a channel. This will only return the correct result after the command has completed so between calling exec and calling this function you should sleep, wait or read the command's input as appropriate.

Arguments:

session The clj-libssh2.session.Session object for the current session. channel The channel on which a command was executed and has exited.

Return:

A map with the following keys and values:

:exit-signal The name of the signal (without the leading "SIG"). :err-msg The error message. :lang-tag The language tag, if provided.

Collect the exit signal data from a channel. This will only return the
correct result after the command has completed so between calling exec and
calling this function you should sleep, wait or read the command's input as
appropriate.

Arguments:

session  The clj-libssh2.session.Session object for the current session.
channel  The channel on which a command was executed and has exited.

Return:

A map with the following keys and values:

:exit-signal The name of the signal (without the leading "SIG").
:err-msg     The error message.
:lang-tag    The language tag, if provided.
sourceraw docstring

exit-statusclj

(exit-status channel)

Get the exit code from the last executed command. This will only return the correct result after the command has completed so between calling exec and calling this function you should sleep, wait or read the command's input as appropriate.

Arguments:

channel The channel on which a command was executed and has exited.

Return:

The numeric exit code from the remote process.

Get the exit code from the last executed command. This will only return the
correct result after the command has completed so between calling exec and
calling this function you should sleep, wait or read the command's input as
appropriate.

Arguments:

channel  The channel on which a command was executed and has exited.

Return:

The numeric exit code from the remote process.
sourceraw docstring

freeclj

(free session channel)

Free a native channel object. Be careful to only call this once. This will implicitly call close if the channel has not already been closed.

Arguments:

session The clj-libssh2.session.Session object for the current session. channel The native channel object to free.

Return:

0 on success or throws an exception on failure.

Free a native channel object. Be careful to only call this once. This will
implicitly call close if the channel has not already been closed.

Arguments:

session  The clj-libssh2.session.Session object for the current session.
channel  The native channel object to free.

Return:

0 on success or throws an exception on failure.
sourceraw docstring

openclj

(open session)

Create a new channel for a session.

Arguments:

session The clj-libssh2.session.Session object for the current session.

Return:

A newly-allocated channel object, or throws exception on failure.

Create a new channel for a session.

Arguments:

session The clj-libssh2.session.Session object for the current session.

Return:

A newly-allocated channel object, or throws exception on failure.
sourceraw docstring

open-scp-recvclj

(open-scp-recv session remote-path)

Create a new channel dedicated to receiving a file using SCP.

Arguments:

session The clj-libssh2.session.Session object for the current session. remote-path The path on the remote machine of the file to receive.

Return:

A map containing a newly-allocated channel object and the Stat object for the file information as reported by the remote host. Throws exception on failure.

Create a new channel dedicated to receiving a file using SCP.

Arguments:

session      The clj-libssh2.session.Session object for the current session.
remote-path  The path on the remote machine of the file to receive.

Return:

A map containing a newly-allocated channel object and the Stat object for
the file information as reported by the remote host. Throws exception on
failure.
sourceraw docstring

open-scp-sendclj

(open-scp-send session remote-path {:keys [atime mode mtime size] :as props})

Create a new channel dedicated to sending a file using SCP.

Arguments:

session The clj-libssh2.session.Session object for the current session. remote-path The path on the remote machine of the file to send. props A map with the following keys and values:

         :atime  The last accessed time to be set on the remote file.
         :mode   The mode that the remote file should have.
         :mtime  The last modified time to be set on the remote file.
         :size   The size of the file in bytes.

Return:

A newly-allocated channel object for sending a file via SCP.

Create a new channel dedicated to sending a file using SCP.

Arguments:

session      The clj-libssh2.session.Session object for the current session.
remote-path  The path on the remote machine of the file to send.
props        A map with the following keys and values:

             :atime  The last accessed time to be set on the remote file.
             :mode   The mode that the remote file should have.
             :mtime  The last modified time to be set on the remote file.
             :size   The size of the file in bytes.

Return:

A newly-allocated channel object for sending a file via SCP.
sourceraw docstring

pullclj

(pull session channel ssh-stream-id output-stream)

Read some output from a given stream on a channel.

Arguments:

session The clj-libssh2.session.Session object for the current session. channel A valid channel for this session. ssh-stream-id 0 for STDOUT, 1 for STDERR or any other number that the process on the other end wishes to send data on. output-stream A java.io.OutputStream to send the data to.

Return:

Either :eof, :eagain or :ready. If :eof, then no more data will be sent. If :eagain, then more data might be available. You should select on the appropriate socket and try again. If :ready, the stream is ready for another read immediately.

Read some output from a given stream on a channel.

Arguments:

session       The clj-libssh2.session.Session object for the current
              session.
channel       A valid channel for this session.
ssh-stream-id 0 for STDOUT, 1 for STDERR or any other number that the
              process on the other end wishes to send data on.
output-stream A java.io.OutputStream to send the data to.

Return:

Either :eof, :eagain or :ready. If :eof, then no more data will be sent. If
:eagain, then more data might be available. You should select on the
appropriate socket and try again. If :ready, the stream is ready for another
read immediately.
sourceraw docstring

pumpclj

(pump session channel input-streams output-streams)

Process a collection of input and output streams all at once. This will run until all streams have reported EOF.

Arguments:

session The clj-libssh2.session.Session object for the current session. channel The SSH channel that we're doing IO on. input-streams A map where the keys are the SSH stream IDs and the values are the InputStream objects used to feed those IDs. output-streams A map where the keys are the SSH stream IDs and the values are the OutputStream objects used to read from those IDs.

Return:

A map where the keys are the SSH output stream IDs and the values are maps with the following keys:

:direction Always :output :id The ID of the SSH stream we're reading from. :last-read-time The last time the stream has been read. :status Always :eof :stream The OutputStream object connected to the SSH stream.

Process a collection of input and output streams all at once. This will run
until all streams have reported EOF.

Arguments:

session        The clj-libssh2.session.Session object for the current
               session.
channel        The SSH channel that we're doing IO on.
input-streams  A map where the keys are the SSH stream IDs and the values
               are the InputStream objects used to feed those IDs.
output-streams A map where the keys are the SSH stream IDs and the values
               are the OutputStream objects used to read from those IDs.

Return:

A map where the keys are the SSH output stream IDs and the values are maps
with the following keys:

:direction       Always :output
:id              The ID of the SSH stream we're reading from.
:last-read-time  The last time the stream has been read.
:status          Always :eof
:stream          The OutputStream object connected to the SSH stream.
sourceraw docstring

pushclj

(push session channel ssh-stream-id input-stream)

Write some input to a given stream on a channel.

Arguments:

session The clj-libssh2.session.Session object for the current session. channel A valid channel for this session. ssh-stream-id 0 for STDIN or any other number that the process on the other end wishes to receive data on. input-stream A java.io.PushbackInputStream to grab the data from. This must be capable of pushing back at least :write-chunk-size bytes.

Return:

Either :eof or :ready. If :eof, then the input-stream has returned -1 and no more data will be read from it nor written to the channel. If :eagain, then you should select on the appropriate socket before calling this again. If :ready then there are more bytes to be processed and this function should be called again.

Write some input to a given stream on a channel.

Arguments:

session       The clj-libssh2.session.Session object for the current
              session.
channel       A valid channel for this session.
ssh-stream-id 0 for STDIN or any other number that the process on the other
              end wishes to receive data on.
input-stream  A java.io.PushbackInputStream to grab the data from. This must
              be capable of pushing back at least :write-chunk-size bytes.

Return:

Either :eof or :ready. If :eof, then the input-stream has returned -1 and no
more data will be read from it nor written to the channel. If :eagain, then
you should select on the appropriate socket before calling this again.  If
:ready then there are more bytes to be processed and this function should be
called again.
sourceraw docstring

readclj

(read session channel ssh-stream-id size)

Attempt to read a chunk of data from a stream on a channel.

Arguments:

session The clj-libssh2.session.Session object for the current session. channel A valid channel for this session. ssh-stream-id 0 for STDOUT, 1 for STDERR or any other number that the process on the other end wishes to send data on. size The number of bytes to request.

Return:

A map with the following keys and values:

:status One of :eof, :ready or :eagain depending on whether the stream has reported EOF, has potentially more bytes to read immediately or has no bytes to read right now but might in the future. :received The number of bytes received. :data A byte array containing the data which was received.

Attempt to read a chunk of data from a stream on a channel.

Arguments:

session       The clj-libssh2.session.Session object for the current
              session.
channel       A valid channel for this session.
ssh-stream-id 0 for STDOUT, 1 for STDERR or any other number that the
              process on the other end wishes to send data on.
size          The number of bytes to request.

Return:

A map with the following keys and values:

:status    One of :eof, :ready or :eagain depending on whether the stream
           has reported EOF, has potentially more bytes to read immediately
           or has no bytes to read right now but might in the future.
:received  The number of bytes received.
:data      A byte array containing the data which was received.
sourceraw docstring

send-eofclj

(send-eof session channel)

Tell the remote process that we won't send any more input.

Arguments:

session The clj-libssh2.session.Session object for the current session. channel The native channel object on which we have finished sending data.

Return:

0 on success, throws an exception on failure.

Tell the remote process that we won't send any more input.

Arguments:

session  The clj-libssh2.session.Session object for the current session.
channel  The native channel object on which we have finished sending data.

Return:

0 on success, throws an exception on failure.
sourceraw docstring

setenvclj

(setenv session channel env)

Set a selection of environment variables on the channel. These will be visible to the next exec command. Setting environment variables may be prohibited by the remote sshd based on the value of the AcceptEnv configuration value.

Arguments:

channel env A map where the keys are environment variable names and the values are the values for those environment variables. If either the name or value is a keyword, they will be stringified using the name function. Everything else will be stringified using str. Nil values will be converted to empty strings. For maximum predictability, you should provide a map of String -> String only.

Return:

0 on success. Errors will result in exceptions.

Set a selection of environment variables on the channel. These will be
visible to the next exec command. Setting environment variables may be
prohibited by the remote sshd based on the value of the AcceptEnv
configuration value.

Arguments:

channel
env      A map where the keys are environment variable names and the values
         are the values for those environment variables. If either the name
         or value is a keyword, they will be stringified using the name
         function. Everything else will be stringified using str. Nil values
         will be converted to empty strings. For maximum predictability, you
         should provide a map of String -> String only.

Return:

0 on success. Errors will result in exceptions.
sourceraw docstring

with-channelcljmacro

(with-channel session channel & body)

Convenience macro for wrapping a bunch of channel operations.

Arguments:

session The clj-libssh2.session.Session object for the current session. channel This will be bound to the result of a call to open.

Convenience macro for wrapping a bunch of channel operations.

Arguments:

session  The clj-libssh2.session.Session object for the current session.
channel  This will be bound to the result of a call to open.
sourceraw docstring

with-scp-recv-channelcljmacro

(with-scp-recv-channel session channel path fileinfo & body)

A convenience macro like with-channel, but for SCP receive operations.

Arguments:

session The clj-libssh2.session.Session object for the current session. channel This will be bound to the channel when it's opened. path The path of the file to receive from the remote machine. fileinfo This will be bound to the Stat struct describing the properties of the remote file.

A convenience macro like with-channel, but for SCP receive operations.

Arguments:

session  The clj-libssh2.session.Session object for the current session.
channel  This will be bound to the channel when it's opened.
path     The path of the file to receive from the remote machine.
fileinfo This will be bound to the Stat struct describing the properties of
         the remote file.
sourceraw docstring

with-scp-send-channelcljmacro

(with-scp-send-channel session channel path props & body)

A convenience macro like with-channel, but for sending files using SCP.

Arguments:

session The clj-libssh2.session.Session object for the current session. channel This will be bound to the channel when it's opened. path The path where the file should be places on the remote machine. props A map describing the properties which should be applied to the file when it's transferred to the other side. The keys and values are as follows:

     :atime  The last accessed time to be set on the remote file.
     :mode   The mode that the remote file should have.
     :mtime  The last modified time to be set on the remote file.
     :size   The size of the file in bytes.
A convenience macro like with-channel, but for sending files using SCP.

Arguments:

session  The clj-libssh2.session.Session object for the current session.
channel  This will be bound to the channel when it's opened.
path     The path where the file should be places on the remote machine.
props    A map describing the properties which should be applied to the
         file when it's transferred to the other side. The keys and values
         are as follows:

         :atime  The last accessed time to be set on the remote file.
         :mode   The mode that the remote file should have.
         :mtime  The last modified time to be set on the remote file.
         :size   The size of the file in bytes.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close