Some Practical Clojure Examples
← prev | next →     Top-level ToC     /managing-processes.html     (printable version)


(System/exit 0)
;; (System/exit)  <-- ERROR

1 Shelling out

(require '[ :as sh])
(sh/sh "tar" "xzf" "foo.tar.gz")
;; ...

;; Req'd to avoid hanging for a minute after use of `sh/sh`.

sh returns a nice map with vals for :exit, :out, and :err.

If you need to include a wildcard in your shell command, maybe try:

(sh/sh "bash" "-c" "ls -l *.txt")

(Thanks to Michael Gardner for that one.)

2 See Also

org.clojars.hozumi/clj-commons-exec (at github) — see Clojure Cookbook recipe 4.3.