fmn
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.
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
I’m aware of 2 such projects, are there others?
git: GitHub - team-alembic/realworld: A fullstack Phoenix LiveView application with back...
New
Hi all,
I’m working on a Phoenix project where I need to make external HTTP requests and I’m trying to choose between Req and HTTPoison....
New
How do I tell Hologram not to escape HTML when substituting into templates?
{Textile.render(@product.long_description)}
escapes the HTM...
New
I’d like to create a file with 600 permissions (rw-------), but there’s a race condition if I create it and then change the permissions. ...
New
Hi,
we run different LLM models across a cluster, with each node loading a configurable subset. Model-specific queues let nodes consume ...
New
When I use Mix.install with a git dependency, using git@github.com:... how do I change the SSH identity used?
I’ve got two Github accoun...
New
Other Trending Topics
Hey there,
I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first.
...
New
Hi everyone :waving_hand:
I wanted to share something I’ve been building — NowBlind, a random chat app designed to help people discover ...
New
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly)
AI dream has many faces, but general...
New
Localize is the next generation localisation library for Elixir. Think of it as ex_cldr version 3.0. The first version will be released ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #code-sync
- #discussion
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #ai
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #blog-post
- #elixirconf-us
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #security
- #elixirconf-eu
- #api
- #forms
- #performance










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
peerreynders
Welcome to the forum!
Have you had a look at this yet (if you were thinking about pipes)?
fmn
Hi @peerreynders, thank you for the response!
With my current knowledge of
ElixirI guess that I can try to achieve what I want with - for example - 2 named pipes or named pipe plusstderrorstdout? All the moving parts around it seem to me bit intimidating.Following links mentioned in the thread you’ve shared, I found also how do I communicate with non-Erlang programs, I guess I will go through it, but it will take time
Thanks again!
F.
peerreynders
While back from 2015 this may still be of some help:
The Erlangelist: Outside Elixir: running external programs with ports
by Saša Jurić, author of Elixir in Action 2e.
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.fmn
Thank you for the reply, much appreciated @OvermindDL1.
Yes, that’s the module I’ve found, but I was searching something more lightweight, native, so to speak, but after your post I think I understand situation better.
As a side-note - it feels quite exotic to me, I’ve never encountered such design during my adventures with other programming languages; it’s interesting.
Cheers,
F.
OvermindDL1
Yeah that is the native way here. ^.^
The only way to do mutability on the BEAM (short of some hacks) is via message passing, and Ports are just “Message Passing” back and forth to an external process designed for it, so it fulfills that model.
Multiple paths of streams doesn’t. So a hoisting program or NIF or something can fill that void by wrapping a higher level layer into the message passing structure. Which is what
erlexecdoes.Yeah the BEAM is not so much a VM like Java, it’s designed to pretend to be it’s own standalone operating system internally within it. ^.^
tme_317
You can also look at porcelain with or without
goonplugin which despite its age still works well for me when I needed stdin control beyond whatSystem.cmdcan provide without digging into low-level Ports.That said
erlexecis better maintained and I found (but not tried) a more idiomatic Elixir wrapper for it exexecNobbZ
There is also
rambowhich might come in handy as an alternative to porcelain and goon, as it’s wrapper does not use go and it’s runtime…fmn
Thank you for all of the suggestions folks!
DiodonHystrix
I had a similar problem, what I did was to pipe stderr to a temp file. A bit ugly, but it worked from what I remember