Namespaces

 
0.2.0-SNAPSHOT Arrow_down_16x16

ssh-shell

clj-ssh.ssh

  • (ssh-shell session in out opts)
Run a ssh-shell.

0 Examples top

Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clj_ssh/ssh.clj:314 top

(defn ssh-shell
  "Run a ssh-shell."
  [#^Session session in out opts]
  (let [#^ChannelShell shell (open-channel session :shell)
        out-stream (java.io.ByteArrayOutputStream.)]
    (doto shell
      (.setInputStream
       (if (string? in)
         (java.io.ByteArrayInputStream. (.getBytes (str in ";exit $?;\n")))
         in)
       false)
      (.setOutputStream out-stream))
    (when (contains? opts :pty)
      (call-method
       com.jcraft.jsch.ChannelSession 'setPty [Boolean/TYPE]
       shell (boolean (opts :pty))))
    (with-connection shell
      (while (connected? shell)
             (Thread/sleep 100))
      [(.getExitStatus shell)
       (if (= :bytes out)
         (.toByteArray out-stream)
         (.toString out-stream out))])))
Vars in clj-ssh.ssh/ssh-shell: with-connection boolean contains? defn doto let str string? when while
Used in 0 other vars

Comments top

No comments for ssh-shell. Log in to add a comment.