autodidaddict

autodidaddict

Author of Real World Event Sourcing

Using environment variables with ports

In this previous post here, the poster asks the same question I have. I cannot seem to get the syntax correct in order to launch a Port with environment variables.

The solution shows how to do it using System.cmd, but I need a port because I need to manage the pid and this executable will be running for a long time. The erlang syntax is also in the original post, but I need to know how to do this in Elixir.

The Elixir code that I have that does not work (gives me “bad argument”) is as follows:

host_info = HostCore.Host.generate_hostinfo_for(public_key)
port = Port.open({:spawn, "#{path}"}, [:binary, {:env, [{'WASMCLOUD_HOST_DATA', host_info}]}] )

Where host_info is just a Jason encoded string.

Marked As Solved

LostKobrakai

LostKobrakai

Based on the typespecs in the erlang docs this needs to be a charlist not a binary.

Also Liked

LostKobrakai

LostKobrakai

Erlang functions often take what is called proplists, which are lists of either atoms, or {atom, value} tuples like elixir keyword lists have.

Last Post!

LostKobrakai

LostKobrakai

Erlang functions often take what is called proplists, which are lists of either atoms, or {atom, value} tuples like elixir keyword lists have.

Where Next?

Popular in Questions Top

JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New

Other popular topics Top

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
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 49134 226
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New

We're in Beta

About us Mission Statement