axelson

axelson

Scenic Core Team

Is there a straightforward way to send a message to my Elixir process from a bash script?

To avoid the XY problem, I am trying to implement a pianobar eventcmd, which is a script that is run on each event (such as song change) and receives the majority of it’s input via stdin. Should I use a pipe? I could do an HTTP Request but that seems awfully inefficient.

Showing Posts 1 to 7

mwgkgk

mwgkgk

Would love to know as well! D-Bus and Websockets come to mind.

ConnorRigby

ConnorRigby

Nerves Core Team

I can think of solving this a number of ways. Do you have distribution available? If not i would use a domain socket if you are on a Linux or OSx machine. (i think OSX supports unix domain sockets)
From an iex session:

{:ok, sock} = :gen_udp.open(0, [{:ifaddr, {:local, '/tmp/testsockin'}}])

and from a shell

echo 'Hello, World!' | socat - UNIX-SENDTO:/tmp/testsockin
axelson

axelson OP

Scenic Core Team

I’m thinking of trying to solve this without distribution since I don’t want to trust the network. That said these two processes will be on the same machine (although there will be another machine running Nerves and Scenic, but that will be a different communication mechanism). The machine running pianobar will be Linux (although it would be nice to support OS X as well).

What advantages does a domain socket have over a named pipe if we want to operate within the same operating system?

ConnorRigby

ConnorRigby

Nerves Core Team

I know how to setup a domain socket and not a named pipe in Elixir :slight_smile:

idi527

idi527

Just in case, you can use something like config :kernel, inet_dist_use_interface: {127, 0, 0, 1} to bind only on localhost (loopback).

lkuty

lkuty

I found that useful to send messages from system cron. Note the use of a backslash in front of %. I have a GenServer called CronServer in charge of parsing the message and calling the appropriate client function in the interested GenServers. I also use sched_ex for cron jobs internal to the app.

5 7 * * * ID=xxx_cron echo "minute. datetime: $(date +'\%FT\%T\%:z')" | socat - UNIX-SENDTO:/tmp/elixir_xxx_cron
— All posts loaded —

Where Next? Top

Trending in Questions Top

Blokh
Hey guys, I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly Do you guys have any suggestions what is the best prac...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
Onor.io
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
jaybe78
Hello, I’m developing a online persistent chat system (what’s app) like using elixir/dynamodb/aws for a mobile app(flutter). The diffic...
New
Trolleger
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
matt-savvy
Anyone here using Honeybadger? My Honeybadger account is being overwhelmed with noise from some bots. Seeing a lot of Bandit.HTTPError...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New

Other Trending Topics Top

garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New
webofbits
Aludel - LLM Evaluation Workbench Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews