A ProcessLogger that writes output to a file.
Represents a process that is running or has finished running.
Represents a runnable process.
Factories for creating ProcessBuilder.
This class is used to control the I/O of every ProcessBuilder.
Provide implicit conversions for the factories offered by Process's companion object.
Encapsulates the output and error streams of a running process.
This object contains factories for ProcessIO,
which can be used to control the I/O of a Process
when a ProcessBuilder is started with the run
command.
Methods for constructing simple commands that can then be combined.
This object contains traits used to describe input and output sources.
Provides factories to create ProcessLogger, which are used to capture output of ProcessBuilder commands when run.
Implicitly convert a java.lang.ProcessBuilder
into a Scala one.
Implicitly convert a java.lang.ProcessBuilder
into a Scala one.
Return a sequence of Source from a sequence
of values for which an implicit conversion to Source
is available.
Return a sequence of Source from a sequence
of values for which an implicit conversion to Source
is available.
Implicitly convert a java.io.File
into a ProcessBuilder
Implicitly convert a java.io.File
into a ProcessBuilder
Implicitly convert a sequence of String
into a ProcessBuilder
Implicitly convert a sequence of String
into a ProcessBuilder
Implicitly convert a String
into a ProcessBuilder
Implicitly convert a String
into a ProcessBuilder
Implicitly convert a java.net.URL
into a ProcessBuilder
Implicitly convert a java.net.URL
into a ProcessBuilder
Implicitly convert a Elem into a ProcessBuilder
Implicitly convert a Elem into a ProcessBuilder
This package is used to create process pipelines, similar to Unix command pipelines.
The key concept is that one builds a Process that will run and return an exit value. This
Process
is usually composed of one or more ProcessBuilder, fed by a Source and feeding a Sink. AProcessBuilder
itself is both aSource
and aSink
.As
ProcessBuilder
,Sink
andSource
are abstract, one usually creates them withapply
methods on the companion object of Process, or through implicit conversions available in this package object fromString
and other types. The pipe is composed through unix-like pipeline and I/O redirection operators available on ProcessBuilder.The example below shows how to build and combine such commands. It searches for
null
uses in thesrc
directory, printing a message indicating whether they were found or not. The first command pipes its output to the second command, whose exit value is then used to choose between the third or fourth commands. This same example is explained in greater detail on ProcessBuilder.Other implicits available here are for FileBuilder, which extends both
Sink
andSource
, and for URLBuilder, which extendsSource
alone.One can even create a
Process
solely out of these, without running any command. For example, this will download from a URL to a file:One may use a
Process
directly throughProcessBuilder
'srun
method, which starts the process in the background, and returns aProcess
. If background execution is not desired, one can get aProcessBuilder
to execute through a method such as!
,lines
,run
or variations thereof. That will create theProcess
to execute the commands, and return either the exit value or the output, maybe throwing an exception.Finally, when executing a
ProcessBuilder
, one may pass a ProcessLogger to capture stdout and stderr of the executing processes. AProcessLogger
may be created through its companion object from functions of type(String) => Unit
, or one might redirect it to a file, using FileProcessLogger, which can also be created throughProcessLogger
's object companion.