erl_call makes it possible to start and/or communicate with a distributed Erlang node. It is built upon the erl_interface library as an example application. Its purpose is to use an Unix shell script to interact with a distributed Erlang node. It performs all communication with the Erlang rex server, using the standard Erlang RPC facility. It does not require any special software to be run at the Erlang target node.
The main use is to either start a distributed Erlang node or to make an ordinary function call. However, it is also possible to pipe an Erlang module to erl_call and have it compiled, or to pipe a sequence of Erlang expressions to be evaluated (similar to the Erlang shell).
Options, which cause stdin to be read, can be used with advantage as scripts from within (Unix) shell scripts. Another nice use of erl_call could be from (http) CGI-bin scripts.
Each option flag is described below with its name, type and meaning.
Starts an Erlang node and calls erlang:time/0.
erl_call -s -a 'erlang time' -n madonna {18,27,34}
Terminates an Erlang node by calling erlang:halt/0.
erl_call -s -a 'erlang halt' -n madonna
An apply with several arguments.
erl_call -s -a 'lists map [{math,sqrt},[1,4,9,16,25]]' -n madonna
Evaluates a couple of 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}}
Compiles a module and runs it. Again, the input ends with EOF (Control-D). (In the example shown, the output has been formatted afterwards).
erl_call -s -m -a lolita -n madonna -module(lolita). -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>, []}]