Namespaces

 
0.2.0-SNAPSHOT Arrow_down_16x16
  • (sftp session-or-hostname cmd & args)
Execute SFTP commands.

sftp host-or-session cmd & options

cmd specifies a command to exec. Valid commands are:
:ls
:put
:get
:chmod
:chown
:chgrp
:cd
:lcd
:pwd
:lpwd
:rm
:rmdir
:stat
:symlink

Options are
:username username to use for authentication
:password password to use for authentication
:port port to use if no session specified

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

(defn sftp
  "Execute SFTP commands.

  sftp host-or-session cmd & options

cmd specifies a command to exec.  Valid commands are:
:ls
:put
:get
:chmod
:chown
:chgrp
:cd
:lcd
:pwd
:lpwd
:rm
:rmdir
:stat
:symlink

Options are
:username   username to use for authentication
:password   password to use for authentication
:port       port to use if no session specified
"
  [session-or-hostname cmd & args]
  (let [opts (parse-args args)
        channel-given (instance? com.jcraft.jsch.ChannelSftp session-or-hostname)
        session-given (instance? com.jcraft.jsch.Session session-or-hostname)
        session (if session-given
                  session-or-hostname
                  (if channel-given
                    nil
                    (default-session
                      session-or-hostname
                      (opts :username)
                      (opts :port)
                      (opts :password))))
        channel (if channel-given
                  session-or-hostname
                  (ssh-sftp session))]
    (try
     (when (and session (not (connected? session)))
       (connect session))
     (let [result (ssh-sftp-cmd channel cmd (opts :cmd) (dissoc opts :cmd))]
       (if (opts :return-map)
         {:exit (first result) :out (second result)}
         result))
     (finally
      (when-not channel-given
        (disconnect channel))
      (when-not (or session-given channel-given)
        (disconnect session))))))
Vars in clj-ssh.ssh/sftp: and defn let not or when when-not
Used in 0 other vars

Comments top

No comments for sftp. Log in to add a comment.