1erl_call(1) User Commands erl_call(1)
2
3
4
6 erl_call - Call/start a distributed Erlang node.
7
9 erl_call makes it possible to start and/or communicate with a distrib‐
10 uted Erlang node. It is built upon the Erl_Interface library as an ex‐
11 ample application. Its purpose is to use a Unix shell script to inter‐
12 act with a distributed Erlang node. It performs all communication with
13 the Erlang rex server, using the standard Erlang RPC facility. It does
14 not require any special software to be run at the Erlang target node.
15
16 The main use is to either start a distributed Erlang node or to make an
17 ordinary function call. However, it is also possible to pipe an Erlang
18 module to erl_call and have it compiled, or to pipe a sequence of Er‐
19 lang expressions to be evaluated (similar to the Erlang shell).
20
21 Options, which cause stdin to be read, can be used with advantage, as
22 scripts from within (Unix) shell scripts. Another nice use of erl_call
23 could be from (HTTP) CGI-bin scripts.
24
26 erl_call <options>
27
28 Starts/calls Erlang.
29
30 Each option flag is described below with its name, type, and
31 meaning.
32
33 -a [Mod [Fun [Args]]]]:
34 (Optional.) Applies the specified function and returns the
35 result. Mod must be specified. However, start and [] are as‐
36 sumed for unspecified Fun and Args, respectively. Args is to
37 be in the same format as for erlang:apply/3 in ERTS.
38
39 Notice that this flag takes exactly one argument, so quoting
40 can be necessary to group Mod, Fun, and Args in a manner de‐
41 pendent on the behavior of your command shell.
42
43 -address [Hostname:]Port:
44 (One of -n, -name, -sname or -address is required.) Hostname
45 is the hostname of the machine that is running the peer node
46 that erl_call shall communicate with. The default hostname
47 is the hostname of the local machine. Port is the port num‐
48 ber of the node that erl_call shall communicate with. The
49 -address flag cannot be combined with any of the flags -n,
50 -name, -sname or -s.
51
52 The -address flag is typically useful when one wants to call
53 a node that is running on machine without an accessible epmd
54 instance.
55
56 -c Cookie:
57 (Optional.) Use this option to specify a certain cookie. If
58 no cookie is specified, the ~/.erlang.cookie file is read
59 and its content is used as cookie. The Erlang node we want
60 to communicate with must have the same cookie.
61
62 -d:
63 (Optional.) Debug mode. This causes all I/O to be output to
64 the ~/.erl_call.out.Nodename file, where Nodename is the
65 node name of the Erlang node in question.
66
67 -e:
68 (Optional.) Reads a sequence of Erlang expressions, sepa‐
69 rated by comma (,) and ended with a full stop (.), from
70 stdin until EOF (Control-D). Evaluates the expressions and
71 returns the result from the last expression. Returns {ok,Re‐
72 sult} on success.
73
74 -h HiddenName:
75 (Optional.) Specifies the name of the hidden node that
76 erl_call represents.
77
78 -m:
79 (Optional.) Reads an Erlang module from stdin and compiles
80 it.
81
82 -n Node:
83 (One of -n, -name, -sname or -address is required.) Has the
84 same meaning as -name and can still be used for backward
85 compatibility reasons.
86
87 -name Node:
88 (One of -n, -name, -sname or -address is required.) Node is
89 the name of the peer node to be started or communicated
90 with. It is assumed that Node is started with erl -name,
91 which means that fully qualified long node names are used.
92 If option -s is specified, an Erlang node will (if neces‐
93 sary) be started with erl -name.
94
95 -q:
96 (Optional.) Halts the Erlang node specified with switch -n.
97 This switch overrides switch -s.
98
99 -r:
100 (Optional.) Generates a random name of the hidden node that
101 erl_call represents.
102
103 -R:
104 (Optional.) Request a dynamic random name, of the hidden
105 node that erl_call represents, from the peer node. Supported
106 since OTP 23. Prefer -R over -r when doing repeated requests
107 toward the same peer node.
108
109 -s:
110 (Optional.) Starts a distributed Erlang node if necessary.
111 This means that in a sequence of calls, where '-s' and '-n
112 Node' are constant, only the first call starts the Erlang
113 node. This makes the rest of the communication very fast.
114 This flag is currently only available on Unix-like platforms
115 (Linux, Mac OS X, Solaris, and so on).
116
117 -sname Node:
118 (One of -n, -name, -sname or -address is required.) Node is
119 the name of the peer node to be started or communicated
120 with. It is assumed that Node is started with erl -sname,
121 which means that short node names are used. If option -s is
122 specified, an Erlang node is started (if necessary) with erl
123 -sname.
124
125 -timeout Seconds:
126 (Optional.) Aborts the erl_call process after the timeout
127 expires. Note that this does not abort commands that have
128 already been started with -a, -e, or similar.
129
130 -v:
131 (Optional.) Prints a lot of verbose information. This is
132 only useful for the developer and maintainer of erl_call.
133
134 -x ErlScript:
135 (Optional.) Specifies another name of the Erlang startup
136 script to be used. If not specified, the standard erl
137 startup script is used.
138
140 To start an Erlang node and call erlang:time/0:
141
142 erl_call -s -a 'erlang time' -n madonna
143 {18,27,34}
144
145
146 To terminate an Erlang node by calling erlang:halt/0:
147
148 erl_call -s -a 'erlang halt' -n madonna
149
150
151 To apply with many arguments:
152
153 erl_call -s -a 'lists seq [1,10]' -n madonna
154
155
156 To evaluate some expressions (the input ends with EOF (Control-D)):
157
158 erl_call -s -e -n madonna
159 statistics(runtime),
160 X=1,
161 Y=2,
162 {_,T}=statistics(runtime),
163 {X+Y,T}.
164 ^D
165 {ok,{3,0}}
166
167
168 To compile a module and run it (again, the input ends with EOF (Con‐
169 trol-D)):
170
171 (In the example, the output has been formatted afterwards.)
172
173 erl_call -s -m -a procnames -n madonna
174 -module(procnames).
175 -compile(export_all).
176 start() ->
177 P = processes(),
178 F = fun(X) -> {X,process_info(X,registered_name)} end,
179 lists:map(F,[],P).
180 ^D
181 [{<madonna@chivas.du.etx.ericsson.se,0,0>,
182 {registered_name,init}},
183 {<madonna@chivas.du.etx.ericsson.se,2,0>,
184 {registered_name,erl_prim_loader}},
185 {<madonna@chivas.du.etx.ericsson.se,4,0>,
186 {registered_name,error_logger}},
187 {<madonna@chivas.du.etx.ericsson.se,5,0>,
188 {registered_name,application_controller}},
189 {<madonna@chivas.du.etx.ericsson.se,6,0>,
190 {registered_name,kernel}},
191 {<madonna@chivas.du.etx.ericsson.se,7,0>,
192 []},
193 {<madonna@chivas.du.etx.ericsson.se,8,0>,
194 {registered_name,kernel_sup}},
195 {<madonna@chivas.du.etx.ericsson.se,9,0>,
196 {registered_name,net_sup}},
197 {<madonna@chivas.du.etx.ericsson.se,10,0>,
198 {registered_name,net_kernel}},
199 {<madonna@chivas.du.etx.ericsson.se,11,0>,
200 []},
201 {<madonna@chivas.du.etx.ericsson.se,12,0>,
202 {registered_name,global_name_server}},
203 {<madonna@chivas.du.etx.ericsson.se,13,0>,
204 {registered_name,auth}},
205 {<madonna@chivas.du.etx.ericsson.se,14,0>,
206 {registered_name,rex}},
207 {<madonna@chivas.du.etx.ericsson.se,15,0>,
208 []},
209 {<madonna@chivas.du.etx.ericsson.se,16,0>,
210 {registered_name,file_server}},
211 {<madonna@chivas.du.etx.ericsson.se,17,0>,
212 {registered_name,code_server}},
213 {<madonna@chivas.du.etx.ericsson.se,20,0>,
214 {registered_name,user}},
215 {<madonna@chivas.du.etx.ericsson.se,38,0>,
216 []}]
217
218
219
220
221Ericsson AB erl_interface 4.0.3.1 erl_call(1)