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…

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.

peerreynders

peerreynders

Welcome to the forum!

Have you had a look at this yet (if you were thinking about pipes)?

Where Next?

Popular in Questions Top

Tee
can someone please explain to me how Enum.reduce works with maps
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
Phillipp
Hey, I have a NanoPi-M3 and try to install Elixir on their Ubuntu image. I followed the Raspberry Pi installation instructions from the ...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
hpopp
To simplify some tasks at work, I wrote and published this package yesterday. It’s a simple macro that enables Access behaviour on struct...
New
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> someth...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
sabri
Can someone explain the settings of pool_size of Ecto in config file? and what is the recommend size? Thanks
New

Other popular topics Top

sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
977 41022 311
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New

We're in Beta

About us Mission Statement