API for shell-out
- ()
by Chris Houser
clojure-contrib is now deprecated
clojure-contrib is no longer being developed or maintained.
Rather than a single, monolithic, contributions library, Clojure now has
a set of separate libraries for each unit of functionality. The libraries
are in the Clojure GitHub organization at
https://github.com/clojure.
API documentation of the libraries can be found at
https://clojure.github.io.
If you're looking for a specific function or namespace from the old
clojure-contrib, see
"Where Did Clojure.Contrib Go".
Full namespace name:
clojure.contrib.shell-out
Overview
Conveniently launch a sub-process providing to its stdin and
collecting its stdout
Public Variables and Functions
sh
function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (sh & args)
Passes the given strings to Runtime.exec() to launch a sub-process.
Options are
:in may be given followed by a String specifying text to be fed to the
sub-process's stdin.
:out option may be given followed by :bytes or a String. If a String
is given, it will be used as a character encoding name (for
example "UTF-8" or "ISO-8859-1") to convert the
sub-process's stdout to a String which is returned.
If :bytes is given, the sub-process's stdout will be stored in
a byte array and returned. Defaults to UTF-8.
:return-map
when followed by boolean true, sh returns a map of
:exit => sub-process's exit code
:out => sub-process's stdout (as byte[] or String)
:err => sub-process's stderr (as byte[] or String)
when not given or followed by false, sh returns a single
array or String of the sub-process's stdout followed by its
stderr
:env override the process env with a map (or the underlying Java
String[] if you are a masochist).
:dir override the process dir with a String or java.io.File.
You can bind :env or :dir for multiple operations using with-sh-env
and with-sh-dir.
Source