View Source ExCmd.Process (ex_cmd v0.12.0)
Server to interact with external process
ExCmd.stream!
should be preferred over this. Use this only if you need more control over the life-cycle of IO streams and OS process.
Summary
Functions
Waits for the program to terminate.
Returns a specification to start this module under a supervisor.
Closes input stream. Which signal EOF to the program
Returns os pid of the command
Returns port_info
Return bytes written by the program to output stream.
Starts a process using cmd_with_args
and with options opts
Returns status of the process. It will be either of :started
, {:done, exit_status}
Kills the program
Writes iodata data
to programs input streams
Functions
Waits for the program to terminate.
If the program terminates before timeout, it returns {:ok, exit_status}
else returns :timeout
Returns a specification to start this module under a supervisor.
See Supervisor
.
Closes input stream. Which signal EOF to the program
Returns os pid of the command
Returns port_info
@spec read(pid(), non_neg_integer() | :infinity) :: {:ok, iodata()} | :eof | {:error, String.t()} | :closed
Return bytes written by the program to output stream.
This blocks until the programs write and flush the output
@spec start_link([String.t(), ...], cd: String.t(), env: [{String.t(), String.t()}], log: boolean() ) :: {:ok, pid()} | {:error, any()}
Starts a process using cmd_with_args
and with options opts
cmd_with_args
must be a list containing command with arguments. example: ["cat", "file.txt"]
.
Options
cd
- the directory to run the command inenv
- a list of tuples containing environment key-value. These can be accessed in the external programlog
- When set totrue
odu logs and command stderr output are logged. Defaults tofalse
Returns status of the process. It will be either of :started
, {:done, exit_status}
Kills the program
@spec write(pid(), iodata(), non_neg_integer() | :infinity) :: :ok | {:error, String.t()} | :closed
Writes iodata data
to programs input streams
This blocks when the pipe is full