API for clojure.java.process - Clojure v1.12.0 (in development)


Full namespace name: clojure.java.process

Overview

A process invocation API wrapping the Java process API.

The primary function here is 'start' which starts a process and handles the
streams as directed. It returns a map that contains keys to access the streams
(if available) and the Java Process object. It is also deref-able to wait for
process exit.

Use ‘slurp' to capture the output of a process stream, and 'ok?’ to wait for a
non-error exit. The 'exec' function handles the common case of `start'ing a
process, waiting for process exit, slurp, and return stdout.

Public Variables and Functions



exec

function
Usage: (exec & opts+args)
Execute a command and on successful exit, return the captured output,
else throw RuntimeException. Args are the same as 'start' and options
if supplied override the default 'exec' settings.

    Added in Clojure version 1.12
Source


from-file

function
Usage: (from-file f)
Coerce f to a file per clojure.java.io/file and return a ProcessBuilder.Redirect reading from the file.
This can be passed to 'start' in :in.

    Added in Clojure version 1.12
Source


ok?

function
Usage: (ok? process-map)
Given the map returned from 'start', wait for the process to exit
and then return true on success

    Added in Clojure version 1.12
Source


start

function
Usage: (start & opts+args)
Start an external command, defined in args.
The process environment vars are inherited from the parent by
default (use :clear-env to clear them).

If needed, provide options in map as first arg:
  :in - a ProcessBuilder.Redirect (default = :pipe) or :inherit
  :out - a ProcessBuilder.Redirect (default = :pipe) or :inherit :discard
  :err - a ProcessBuilder.Redirect (default = :pipe) or :inherit :discard :stdout
  :dir - current directory when the process runs (default=".")
  :clear-env - if true, remove all inherited parent env vars
  :env - {env-var value} of environment variables to set (all strings)

Returns an ILookup containing the java.lang.Process in :process and the
streams :in :out :err. The map is also an IDeref that waits for process exit
and returns the exit code.

    Added in Clojure version 1.12
Source


to-file

function
Usage: (to-file f & {:keys [append], :as opts})
Coerce f to a file per clojure.java.io/file and return a ProcessBuilder.Redirect writing to the file.
Set ':append' in opts to append. This can be passed to 'start' in :out or :err.

    Added in Clojure version 1.12
Source
Logo & site design by Tom Hickey.
Clojure auto-documentation system by Tom Faulhaber.