A library for executing external processes and managing their shell
The library centers around two functions in
run covers the most common use case of executing an external
process and capturing the contents of its
stdout as a string. The
call returns a future, which can be dereferenced to get the contents of
stdout. If the process exits with a non-zero error code, an
ex-info is thrown containing the contents of
stderr as well as the
exit code of the process.
exec provides for more sophisticated use cases like streaming the
output of a process as it is executing etc. The function is
accompanied by a series of functions allowing the caller to interact
stderr. The following code segment prints
the contents of the
stdout for a process as they become available
stdout-seq which provides a lazy sequence of lines.
(require '[crusta.core :refer [exec stdout-seq]])
(let [p (exec "some-long-running-command with-parameters")]
(doseq [line (stdout-seq p)]
The 'command' passed to both functions can take the form of a single
string or a sequence of strings. Additionally environment variables
and working directories etc. can be specified via keyword parameters
documented in the doc strings of the individual functions.
Copyright © 2017 7theta
Distributed under the Eclipse Public License.