fmn

fmn

Stderr and stdout of external program

Hello there!

I am exploring ways of running external programs via Elixir, and to my surprise I didn’t found a way to read from called program’s stdout and stderr separately.

It seems that this is related to how Erlang primitives are handling that task.
Only thing I found, is open_port/2’s stderr_to_stdout option, to merge both streams, and it seems Elixir’s Port.open does the same.

I found some external modules for Erlang supposedly addressing my need, but my question would be: is there elegant / native way to do it in Elixir?

Alternatively, is there a way to call bare sysalls on POSIX platform?

P.S. I wasn’t really sure where to post that question or how exactly label / tag it - my apologies if something went wrong here!

Kind regards,
F.

Most Liked

OvermindDL1

OvermindDL1

For note, Port’s are more for running with programs designed to work with your BEAM program, it’s less for running ‘other’ things as it doesn’t have this control over file descriptors, PID handling, or anything. If you want to manage programs that aren’t designed to be Port programs then I recommend using something like erlexec or so as it uses a shim C program to act as the binding layer between a Port call and Everything else.

tme_317

tme_317

You can also look at porcelain with or without goon plugin which despite its age still works well for me when I needed stdin control beyond what System.cmd can provide without digging into low-level Ports.

That said erlexec is better maintained and I found (but not tried) a more idiomatic Elixir wrapper for it exexec

NobbZ

NobbZ

There is also rambo which might come in handy as an alternative to porcelain and goon, as it’s wrapper does not use go and it’s runtime…

Last Post!

axelson

axelson

Scenic Core Team

Yeah, I’ve had good success with erlexec in the past. Just used it directly, wasn’t too bad, although I do remember running into a bump or two configuring it.

Where Next?

Popular in Questions Top

nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New

Other popular topics Top

nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 54006 488
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 31494 112
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New

We're in Beta

About us Mission Statement