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 -c Cookie:
45 (Optional.) Use this option to specify a certain cookie. If
46 no cookie is specified, the ~/.erlang.cookie file is read
47 and its content is used as cookie. The Erlang node we want
48 to communicate with must have the same cookie.
49
50 -d:
51 (Optional.) Debug mode. This causes all I/O to be output to
52 the ~/.erl_call.out.Nodename file, where Nodename is the
53 node name of the Erlang node in question.
54
55 -e:
56 (Optional.) Reads a sequence of Erlang expressions, sepa‐
57 rated by comma (,) and ended with a full stop (.), from
58 stdin until EOF (Control-D). Evaluates the expressions and
59 returns the result from the last expression. Returns
60 {ok,Result} on success.
61
62 -h HiddenName:
63 (Optional.) Specifies the name of the hidden node that
64 erl_call represents.
65
66 -m:
67 (Optional.) Reads an Erlang module from stdin and compiles
68 it.
69
70 -n Node:
71 (One of -n, -name, -sname is required.) Has the same meaning
72 as -name and can still be used for backward compatibility
73 reasons.
74
75 -name Node:
76 (One of -n, -name, -sname is required.) Node is the name of
77 the node to be started or communicated with. It is assumed
78 that Node is started with erl -name, which means that fully
79 qualified long node names are used. If option -s is speci‐
80 fied, an Erlang node will (if necessary) be started with erl
81 -name.
82
83 -q:
84 (Optional.) Halts the Erlang node specified with switch -n.
85 This switch overrides switch -s.
86
87 -r:
88 (Optional.) Generates a random name of the hidden node that
89 erl_call represents.
90
91 -s:
92 (Optional.) Starts a distributed Erlang node if necessary.
93 This means that in a sequence of calls, where '-s' and '-n
94 Node' are constant, only the first call starts the Erlang
95 node. This makes the rest of the communication very fast.
96 This flag is currently only available on Unix-like platforms
97 (Linux, Mac OS X, Solaris, and so on).
98
99 -sname Node:
100 (One of -n, -name, -sname is required.) Node is the name of
101 the node to be started or communicated with. It is assumed
102 that Node is started with erl -sname, which means that short
103 node names are used. If option -s is specified, an Erlang
104 node is started (if necessary) with erl -sname.
105
106 -v:
107 (Optional.) Prints a lot of verbose information. This is
108 only useful for the developer and maintainer of erl_call.
109
110 -x ErlScript:
111 (Optional.) Specifies another name of the Erlang startup
112 script to be used. If not specified, the standard erl
113 startup script is used.
114
116 To start an Erlang node and call erlang:time/0:
117
118 erl_call -s -a 'erlang time' -n madonna
119 {18,27,34}
120
121
122 To terminate an Erlang node by calling erlang:halt/0:
123
124 erl_call -s -a 'erlang halt' -n madonna
125
126
127 To apply with many arguments:
128
129 erl_call -s -a 'lists seq [1,10]' -n madonna
130
131
132 To evaluate some expressions (the input ends with EOF (Control-D)):
133
134 erl_call -s -e -n madonna
135 statistics(runtime),
136 X=1,
137 Y=2,
138 {_,T}=statistics(runtime),
139 {X+Y,T}.
140 ^D
141 {ok,{3,0}}
142
143
144 To compile a module and run it (again, the input ends with EOF (Con‐
145 trol-D)):
146
147 (In the example, the output has been formatted afterwards.)
148
149 erl_call -s -m -a procnames -n madonna
150 -module(procnames).
151 -compile(export_all).
152 start() ->
153 P = processes(),
154 F = fun(X) -> {X,process_info(X,registered_name)} end,
155 lists:map(F,[],P).
156 ^D
157 [{<madonna@chivas.du.etx.ericsson.se,0,0>,
158 {registered_name,init}},
159 {<madonna@chivas.du.etx.ericsson.se,2,0>,
160 {registered_name,erl_prim_loader}},
161 {<madonna@chivas.du.etx.ericsson.se,4,0>,
162 {registered_name,error_logger}},
163 {<madonna@chivas.du.etx.ericsson.se,5,0>,
164 {registered_name,application_controller}},
165 {<madonna@chivas.du.etx.ericsson.se,6,0>,
166 {registered_name,kernel}},
167 {<madonna@chivas.du.etx.ericsson.se,7,0>,
168 []},
169 {<madonna@chivas.du.etx.ericsson.se,8,0>,
170 {registered_name,kernel_sup}},
171 {<madonna@chivas.du.etx.ericsson.se,9,0>,
172 {registered_name,net_sup}},
173 {<madonna@chivas.du.etx.ericsson.se,10,0>,
174 {registered_name,net_kernel}},
175 {<madonna@chivas.du.etx.ericsson.se,11,0>,
176 []},
177 {<madonna@chivas.du.etx.ericsson.se,12,0>,
178 {registered_name,global_name_server}},
179 {<madonna@chivas.du.etx.ericsson.se,13,0>,
180 {registered_name,auth}},
181 {<madonna@chivas.du.etx.ericsson.se,14,0>,
182 {registered_name,rex}},
183 {<madonna@chivas.du.etx.ericsson.se,15,0>,
184 []},
185 {<madonna@chivas.du.etx.ericsson.se,16,0>,
186 {registered_name,file_server}},
187 {<madonna@chivas.du.etx.ericsson.se,17,0>,
188 {registered_name,code_server}},
189 {<madonna@chivas.du.etx.ericsson.se,20,0>,
190 {registered_name,user}},
191 {<madonna@chivas.du.etx.ericsson.se,38,0>,
192 []}]
193
194
195
196
197Ericsson AB erl_interface 3.11.3 erl_call(1)