0.2.0-SNAPSHOT Arrow_down_16x16



  • (ssh-exec session cmd in out opts)
Run a command via ssh-exec.

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:338 top

(defn ssh-exec
  "Run a command via ssh-exec."
  [#^Session session #^String cmd in out opts]
  (let [#^ChannelExec exec (open-channel session :exec)
        out-stream (
        err-stream (]
    (doto exec
       (if (string? in)
         ( (.getBytes #^String in))
      (.setOutputStream out-stream)
      (.setErrStream err-stream)
      (.setCommand cmd))
    (when (contains? opts :pty)
       com.jcraft.jsch.ChannelSession 'setPty [Boolean/TYPE]
       exec (boolean (opts :pty))))
    (with-connection exec
      (while (connected? exec)
             (Thread/sleep 100))
      [(.getExitStatus exec)
       (if (= :bytes out)
        (.toByteArray out-stream)
        (.toString out-stream out))
       (if (= :bytes out)
        (.toByteArray err-stream)
        (.toString err-stream out))])))
Vars in clj-ssh.ssh/ssh-exec: with-connection boolean contains? defn doto let string? when while
Used in 0 other vars

Comments top

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