(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))])))
Used in 0 other vars
Comments top
No comments for ssh-shell. Log in to add a comment.