Skip to content

Instantly share code, notes, and snippets.

@Licenser
Created November 16, 2009 13:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save Licenser/a6e903ef4c7998d82d34 to your computer and use it in GitHub Desktop.
Save Licenser/a6e903ef4c7998d82d34 to your computer and use it in GitHub Desktop.
(defn do-sftp-fn
[sftp commands]
(map (fn [command]
(let
[cmd_is? (partial = (first command))
opts (next command)
_ (println "cmd " command) ]
(cond
(cmd_is? :put) (do
(println (str "put " (first opts) " " (second opts) "."))
(.put sftp (first opts) (second opts)))
(cmd_is? :get) (do
(println (str "get " (first opts) " " (second opts) "."))
(.get sftp (first opts) (second opts)))
))) commands))
(defmacro do-sftp
[& commands]
`(let
[sftp# (.openChannel ~'session "sftp")]
(.connect sftp#)
(do-sftp-fn sftp# '~commands)
(println-str '~commands)
(.disconnect sftp#)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment