How to pass a vector of strings to in clojure?

I am trying to make use of (require [ :refer [sh]]) to execute rsync backups in clojure. The function sh takes strings as args such as:

(sh "ls" "-las" "/home/")

However, I find myself with data arriving to sh as a vector of strings (e.g ["ls" "-las" "/home/"]) and this of course fails. This seems like what would be an extremely easy problem to solve, but I am just starting clojure (and lisp and functional programming by that matter) and I just can't seem to get this to work. How can I process the vector to pass to sh?

Any advice would be greatly appreciated.


It sounds like you need to use apply:

(apply sh arg-vector)

The apply function also pops up in other LISPs, allowing you to pass a list of arguments to a given function. In Clojure you're not limited to just lists, but any seq-able object, including vectors.

Need Your Help

Facebook Requires extended permission: publish_actions

facebook facebook-graph-api facebook-apps

I'm in the process of developing a Contest and Promotion-related Facebook app and my intent is to to create a tab on my company's page that will provide access to the app.

Simulate Keyboard Event

.net events keyboard virtual keypress

I am trying to insert string values to a third party application say, notepad. Below is the code that I am using