axelson
How can I send a process a message from a shell script?
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.
First Post!
mwgkgk
Most Liked
ConnorRigby
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
peerreynders
ConnorRigby
Last Post!
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
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









