erl_call(1)
π erl_call β the girlboss way to call/start a distributed Erlang node π
okay bestie, strap in, this is erl_call(1) from the erl_interface manual, and it's genuinely one of the most underrated little utilities out there. no cap. π¦
β¨ NAME β¨
erl_call β call/start a distributed Erlang node π
πΈ DESCRIPTION πΈ
so erl_call makes it possible to start and/or communicate with a distributed Erlang node. it's built on the Erl_Interface library as an example application, and its whole purpose is letting you use a Unix shell script to interact with a distributed Erlang node. it does all its talking to the Erlang rex server using the standard Erlang RPC facility. and the slay part? it does not require any special software to be run at the Erlang target node. iconic. π
the main use is either to start a distributed Erlang node or to make an ordinary function call. but also (and this is the fun part) you can pipe an Erlang module to erl_call and have it compiled, or pipe a sequence of Erlang expressions to be evaluated β basically like the Erlang shell but make it shell-script chic. π
options that cause stdin to be read? use them with advantage in scripts from within (Unix) shell scripts. another nice use of erl_call could be from (HTTP) CGI-bin scripts. the versatility, honestly. π
π erl_call <options> π
starts/calls Erlang. that's the whole vibe.
each option flag is described below with its name, type, and meaning. i'm not skipping a single one, bestie, we're going all the way. β¨
-a [Mod [Fun [Args]]]]β (optional.) applies the specified function and returns the result.Modmust be specified. however,startand[]are assumed for unspecifiedFunandArgs, respectively.Argsis to be in the same format as forerlang:apply/3in ERTS except only a subset of all terms are allowed. the allowed term types are:list(and string representation of list, that is"example"),tuple,atomandnumber.
notice that this flag takes exactly one argument, so quoting can be necessary to group Mod, Fun, and Args in a manner dependent on the behavior of your command shell. yes, the shell will absolutely humble you here. π
-address [Hostname:]Portβ (one of-n,-name,-snameor-addressis required.)Hostnameis the hostname of the machine that is running the peer node thaterl_callwill communicate with. the default hostname is the hostname of the local machine.Portis the port number of the node thaterl_callwill communicate with. the-addressflag cannot be combined with any of the flags-n,-name,-snameor-s.
the -address flag is typically useful when one wants to call a node that is running on machine without an accessible epmd instance. so like, no epmd, no problem. π«Ά
-c Cookieβ (optional.) use this option to specify a certain cookie. if no cookie is specified, the~/.erlang.cookiefile is read and its content is used as cookie. the Erlang node we want to communicate with must have the same cookie. matching cookies only, it's giving soulmate energy fr fr. π-dβ (optional.) debug mode. this causes all I/O to be output to the~/.erl_call.out.Nodenamefile, whereNodenameis the node name of the Erlang node in question.-eβ (optional.) reads a sequence of Erlang expressions, separated by comma (,) and ended with a full stop (.), from stdin until EOF (Control+D). evaluates the expressions and returns the result from the last expression. returns{ok,Result}on success. cute, clean, done. β¨-fetch_stdoutβ (optional.) executes the code, specified with the-aor-eoption, in a new process that has a group leader that forwards all stdout (standard output) data so that it is printed to stdout of theerl_callprocess. this means that stdout data that are written during the execution of the called code, by the code and by descendant processes, will be forwarded (given that the group leader has not been changed by a call toerlang:group_leader/2).
the printed data is UTF-8 encoded. π
this option is only relevant combined with the -a or -e option.
see the documentation of the I/O protocol for more information about the group leader concept.
NOTE: this option only works when erl_call is interacting with a node with a version greater or equal to OTP-24. so version check first, bestie, don't get caught lacking. π
-h HiddenNameβ (optional.) specifies the name of the hidden node thaterl_callrepresents. stealth mode: activated. π§-mβ (optional.) reads an Erlang module from stdin and compiles it. living that pipe-it-in lifestyle. πΈ-n Nodeβ (one of-n,-name,-snameor-addressis required.) has the same meaning as-nameand can still be used for backward compatibility reasons. legacy but still iconic, honestly. π-name Nodeβ (one of-n,-name,-snameor-addressis required.)Nodeis the name of the peer node to be started or communicated with. it is assumed thatNodeis started witherl -name, which means that fully qualified long node names are used. if option-sis specified, an Erlang node will (if necessary) be started witherl -name.-no_result_termβ (optional.) do not print the result term. this option is only relevant together with the options-aand-e. sometimes you just want the side effects and zero commentary. valid. π-qβ (optional.) halts the Erlang node specified with switch-n. this switch overrides switch-s. yeah, it really said "no-stoday". π-rβ (optional.) generates a random name of the hidden node thaterl_callrepresents.-Rβ (optional.) request a dynamic random name, of the hidden node thaterl_callrepresents, from the peer node. supported since OTP 23. prefer-Rover-rwhen doing repeated requests toward the same peer node. lowkey the glow-up version of-r. π₯-sβ (optional.) starts a distributed Erlang node if necessary. this means that in a sequence of calls, where'-s'and'-n Node'are constant, only the first call starts the Erlang node. this makes the rest of the communication very fast. β this flag is currently only available on Unix-like platforms (Linux, Mac OS X, Solaris, and so on).-sname Nodeβ (one of-n,-name,-snameor-addressis required.)Nodeis the name of the peer node to be started or communicated with. it is assumed thatNodeis started witherl -sname, which means that short node names are used. if option-sis specified, an Erlang node is started (if necessary) witherl -sname.-timeout Secondsβ (optional.) aborts theerl_callprocess after the timeout expires. note that this does not abort commands that have already been started with-a,-e, or similar. so the timer stops waiting on you, but it doesn't stop what's already running. important distinction, bestie. β³-vβ (optional.) prints a lot of verbose information. this is only useful for the developer and maintainer oferl_call. (hi devs, we love you π«Ά)-x ErlScriptβ (optional.) specifies another name of the Erlang startup script to be used. if not specified, the standarderlstartup script is used. custom script, custom era. π
π¦ Examples π¦
to start an Erlang node and call erlang:time/0:
erl_call -s -a 'erlang time' -n madonna
{18,27,34}
to terminate an Erlang node by calling erlang:halt/0:
erl_call -s -a 'erlang halt' -n madonna
to apply with many arguments:
erl_call -s -a 'lists seq [1,10]' -n madonna
to evaluate some expressions (the input ends with EOF (Control+D)):
erl_call -s -e -n madonna
statistics(runtime),
X=1,
Y=2,
{_,T}=statistics(runtime),
{X+Y,T}.
^D
{ok,{3,0}}
to compile a module and run it (again, the input ends with EOF (Control+D)):
(in the example, the output has been formatted afterwards.)
erl_call -s -m -a procnames -n madonna
-module(procnames).
-compile(export_all).
start() ->
P = processes(),
F = fun(X) -> {X,process_info(X,registered_name)} end,
lists:map(F,[],P).
^D
[{<madonna@chivas.du.etx.ericsson.se,0,0>,
{registered_name,init}},
{<madonna@chivas.du.etx.ericsson.se,2,0>,
{registered_name,erl_prim_loader}},
{<madonna@chivas.du.etx.ericsson.se,4,0>,
{registered_name,error_logger}},
{<madonna@chivas.du.etx.ericsson.se,5,0>,
{registered_name,application_controller}},
{<madonna@chivas.du.etx.ericsson.se,6,0>,
{registered_name,kernel}},
{<madonna@chivas.du.etx.ericsson.se,7,0>,
[]},
{<madonna@chivas.du.etx.ericsson.se,8,0>,
{registered_name,kernel_sup}},
{<madonna@chivas.du.etx.ericsson.se,9,0>,
{registered_name,net_sup}},
{<madonna@chivas.du.etx.ericsson.se,10,0>,
{registered_name,net_kernel}},
{<madonna@chivas.du.etx.ericsson.se,11,0>,
[]},
{<madonna@chivas.du.etx.ericsson.se,12,0>,
{registered_name,global_name_server}},
{<madonna@chivas.du.etx.ericsson.se,13,0>,
{registered_name,auth}},
{<madonna@chivas.du.etx.ericsson.se,14,0>,
{registered_name,rex}},
{<madonna@chivas.du.etx.ericsson.se,15,0>,
[]},
{<madonna@chivas.du.etx.ericsson.se,16,0>,
{registered_name,file_server}},
{<madonna@chivas.du.etx.ericsson.se,17,0>,
{registered_name,code_server}},
{<madonna@chivas.du.etx.ericsson.se,20,0>,
{registered_name,user}},
{<madonna@chivas.du.etx.ericsson.se,38,0>,
[]}]
to forward standard output without printing the result term (again, the input ends with EOF (Control+D)):
erl_call -s -e -sname madonna -fetch_stdout -no_result_term
io:format("Number of schedulers: ~p~n", [erlang:system_info(schedulers)]),
io:format("Number of logical cores: ~p~n", [erlang:system_info(logical_processors_available)]).
^D
Number of schedulers: 8
Number of logical cores: 8
and that's the whole page, bestie!! π this was brought to you by Ericsson AB, straight outta the erl_interface 5.8.2 release β so if you ever need to cite your sources for the group chat, that's them, and that's the erl_call(1) manual page, periodt. πβ¨ go call some nodes, you absolute main character. ππ¦
π¦ where this page comes from
- arch rolling: erlang-erl_interface 29.1.1-1 Β· Apache-2.0
- nixos 26.05: erlang 29.1.2
- nixpkgs unstable: erlang 29.1.2
- ubuntu stonking: erlang-base 1:29.0.6+dfsg-1 Β· Apache-2.0
- ubuntu stonking: erlang-doc 1:29.0.6+dfsg-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms