Simplest way to tell local erlang node from shell command

I am running a erlang distributed system with one node per machine.

Since DNS is not available, I all start them with the same -snameparameter, for example.

erl -sname foo ...

The operating system daemon has a function for executing shell commands ( /bin/sh) when a certain event occurs (when a USB drive is connected to the system).

I am looking for an easy way to call a function on erlang node local on this computer using this shell command (take further action after locating and installing the USB drive).

I was thinking of calling erl -sname barfrom a shell and running code that looks like

[_,Host] = string:tokens(atom_to_list(node()), "@"),
The_node = list_to_atom("foo@" ++ Host),
spawn(The_node, My_fun),

Is that the way? Or launches a brand new erlang node overkill (often will not do this)

, gen_tcp, .

?

, Unix.

+5
1

, , erl_call, , .

erl_call / Erlang node. erl_interface . - Unix script Erlang node.

, escript, , . .

+9

All Articles