Raxol. System. PortCommand
(Raxol v2.6.0)
View Source
Utility for running external commands with stdin input via Port.
This module provides a way to execute external commands and pass data to their stdin, which System.cmd/3 doesn't support directly.
Summary
Functions
Runs a command with the given arguments, passing input to stdin.
Functions
@spec run(String.t(), [String.t()], String.t(), keyword()) :: {:ok, String.t()} | {:error, String.t()}
Runs a command with the given arguments, passing input to stdin.
Returns {:ok, output} on success (exit code 0) or {:error, output} on failure.
Options
:timeout- Maximum time to wait for the command in milliseconds (default: 30000)
Examples
iex> PortCommand.run("cat", [], "hello")
{:ok, "hello"}
iex> PortCommand.run("grep", ["pattern"], "no match here")
{:error, ""}