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