System.shell
You're seeing just the function
shell
, go back to System module for more information.
Specs
shell(binary(), keyword()) :: {Collectable.t(), exit_status :: non_neg_integer()}
Executes the given command
in the OS shell.
It uses sh
for Unix-like systems and cmd
for Windows.
Important: Use this function with care. In particular, never
pass untrusted user input to this function, as the user would be
able to perform "command injection attacks" by executing any code
directly on the machine. Generally speaking, prefer to use cmd/3
over this function.
Examples
iex> System.shell("echo hello")
{"hello\n", 0}
If you want to stream the devices to IO as they come:
iex> System.shell("echo hello", into: IO.stream())
hello
{%IO.Stream{}, 0}
Options
It accepts the same options as cmd/3
, except for arg0
.