saleyn / erlexec

Execute and control OS processes from Erlang/OTP
https://hexdocs.pm/erlexec/readme.html
Other
525 stars 139 forks source link

Passing command arguments as list #169

Closed george-hopkins closed 1 year ago

george-hopkins commented 1 year ago

I am trying to run a command by passing a list of arguments:

iex> :exec.run("echo ok", [:sync, :stdout])
{:ok, [stdout: ["ok\n"]]}
iex> :exec.run(["echo", "ok"], [:sync, :stdout])
{:error, [exit_status: 256]}

Is this not supported yet or just a bug (#21)?

saleyn commented 1 year ago

You have to give it a full path to the executable if you are using the list notation (see this example):

:exec.run(["/bin/echo", "ok"], [:sync, :stdout])
{:ok, [stdout: ["ok\n"]]}