Erlang -- erl_call

Erl_Interface

Reference Manual

Version 3.10.3

- User's Guide
- Reference Manual
- Release Notes
- PDF
- Top

- Expand All
- Contract All

### Table of Contents

- ei
  - Top of manual page
  - ei_decode_atom()
  - ei_decode_atom_as()
  - ei_decode_bignum()
  - ei_decode_binary()
  - ei_decode_boolean()
  - ei_decode_char()
  - ei_decode_double()
  - ei_decode_ei_term()
  - ei_decode_fun()
  - ei_decode_list_header()
  - ei_decode_long()
  - ei_decode_longlong()
  - ei_decode_map_header()
  - ei_decode_pid()
  - ei_decode_port()
  - ei_decode_ref()
  - ei_decode_string()
  - ei_decode_term()
  - ei_decode_trace()
  - ei_decode_tuple_header()
  - ei_decode_ulong()
  - ei_decode_ulonglong()
  - ei_decode_version()
  - ei_encode_atom()
  - ei_encode_atom_as()
  - ei_encode_atom_len()
  - ei_encode_atom_len_as()
  - ei_encode_bignum()
  - ei_encode_binary()
  - ei_encode_boolean()
  - ei_encode_char()
  - ei_encode_double()
  - ei_encode_empty_list()
  - ei_encode_fun()
  - ei_encode_list_header()
  - ei_encode_long()
  - ei_encode_longlong()
  - ei_encode_map_header()
  - ei_encode_pid()
  - ei_encode_port()
  - ei_encode_ref()
  - ei_encode_string()
  - ei_encode_string_len()
  - ei_encode_term()
  - ei_encode_trace()
  - ei_encode_tuple_header()
  - ei_encode_ulong()
  - ei_encode_ulonglong()
  - ei_encode_version()
  - ei_get_type()
  - ei_print_term()
  - ei_s_print_term()
  - ei_set_compat_rel()
  - ei_skip_term()
  - ei_x_append()
  - ei_x_append_buf()
  - ei_x_encode_atom()
  - ei_x_encode_atom_as()
  - ei_x_encode_atom_len()
  - ei_x_encode_atom_len_as()
  - ei_x_encode_bignum()
  - ei_x_encode_binary()
  - ei_x_encode_boolean()
  - ei_x_encode_char()
  - ei_x_encode_double()
  - ei_x_encode_empty_list()
  - ei_x_encode_fun()
  - ei_x_encode_list_header()
  - ei_x_encode_long()
  - ei_x_encode_longlong()
  - ei_x_encode_map_header()
  - ei_x_encode_pid()
  - ei_x_encode_port()
  - ei_x_encode_ref()
  - ei_x_encode_string()
  - ei_x_encode_string_len()
  - ei_x_encode_term()
  - ei_x_encode_trace()
  - ei_x_encode_tuple_header()
  - ei_x_encode_ulong()
  - ei_x_encode_ulonglong()
  - ei_x_encode_version()
  - ei_x_format()
  - ei_x_format_wo_ver()
  - ei_x_free()
  - ei_x_new()
  - ei_x_new_with_version()
  - free_fun()
- ei_connect
  - Top of manual page
  - *ei_gethostbyaddr()
  - *ei_gethostbyaddr_r()
  - *ei_gethostbyname()
  - *ei_gethostbyname_r()
  - ei_accept()
  - ei_accept_tmo()
  - ei_connect()
  - ei_connect_init()
  - ei_connect_tmo()
  - ei_connect_xinit()
  - ei_get_tracelevel()
  - ei_publish()
  - ei_publish_tmo()
  - ei_receive()
  - ei_receive_encoded()
  - ei_receive_encoded_tmo()
  - ei_receive_msg()
  - ei_receive_msg_tmo()
  - ei_receive_tmo()
  - ei_reg_send()
  - ei_reg_send_tmo()
  - ei_rpc()
  - ei_rpc_from()
  - ei_rpc_to()
  - ei_self()
  - ei_send()
  - ei_send_encoded()
  - ei_send_encoded_tmo()
  - ei_send_reg_encoded()
  - ei_send_reg_encoded_tmo()
  - ei_send_tmo()
  - ei_set_tracelevel()
  - ei_thisalivename()
  - ei_thishostname()
  - ei_thisnodename()
  - ei_unpublish()
  - ei_unpublish_tmo()
  - ei_xconnect()
  - ei_xconnect_tmo()
  - ei_xreceive_msg()
  - ei_xreceive_msg_tmo()
- registry
  - Top of manual page
  - ei_reg_close()
  - ei_reg_delete()
  - ei_reg_dump()
  - ei_reg_getfval()
  - ei_reg_getival()
  - ei_reg_getpval()
  - ei_reg_getsval()
  - ei_reg_getval()
  - ei_reg_markdirty()
  - ei_reg_open()
  - ei_reg_purge()
  - ei_reg_resize()
  - ei_reg_restore()
  - ei_reg_setfval()
  - ei_reg_setival()
  - ei_reg_setpval()
  - ei_reg_setsval()
  - ei_reg_setval()
  - ei_reg_stat()
  - ei_reg_tabstat()
- erl_connect
  - Top of manual page
  - *erl_gethostbyaddr()
  - *erl_gethostbyaddr_r()
  - *erl_gethostbyname()
  - *erl_gethostbyname_r()
  - erl_accept()
  - erl_close_connection()
  - erl_connect()
  - erl_connect_init()
  - erl_connect_xinit()
  - erl_publish()
  - erl_receive()
  - erl_receive_msg()
  - erl_reg_send()
  - erl_rpc()
  - erl_rpc_from()
  - erl_rpc_to()
  - erl_send()
  - erl_thisalivename()
  - erl_thiscookie()
  - erl_thiscreation()
  - erl_thishostname()
  - erl_thisnodename()
  - erl_unpublish()
  - erl_xconnect()
  - erl_xreceive_msg()
- erl_error
  - Top of manual page
  - erl_err_msg()
  - erl_err_quit()
  - erl_err_ret()
  - erl_err_sys()
  - erl_errno()
- erl_eterm
  - Top of manual page
  - erl_cons()
  - erl_copy_term()
  - erl_element()
  - erl_hd()
  - erl_init()
  - erl_iolist_length()
  - erl_iolist_to_binary()
  - erl_iolist_to_string()
  - erl_length()
  - erl_mk_atom()
  - erl_mk_binary()
  - erl_mk_empty_list()
  - erl_mk_estring()
  - erl_mk_float()
  - erl_mk_int()
  - erl_mk_list()
  - erl_mk_long_ref()
  - erl_mk_pid()
  - erl_mk_port()
  - erl_mk_ref()
  - erl_mk_string()
  - erl_mk_tuple()
  - erl_mk_uint()
  - erl_mk_var()
  - erl_print_term()
  - erl_set_compat_rel()
  - erl_size()
  - erl_tl()
  - erl_var_content()
- erl_format
  - Top of manual page
  - erl_format()
  - erl_match()
- erl_global
  - Top of manual page
  - erl_global_names()
  - erl_global_register()
  - erl_global_unregister()
  - erl_global_whereis()
- erl_malloc
  - Top of manual page
  - erl_alloc_eterm()
  - erl_eterm_release()
  - erl_eterm_statistics()
  - erl_free()
  - erl_free_array()
  - erl_free_compound()
  - erl_free_term()
  - erl_malloc()
- erl_marshal
  - Top of manual page
  - erl_compare_ext()
  - erl_decode()
  - erl_decode_buf()
  - erl_encode()
  - erl_encode_buf()
  - erl_ext_size()
  - erl_ext_type()
  - erl_peek_ext()
  - erl_term_len()
- erl_call

# erl_call

### Command

erl_call

### Command Summary

Call/start a distributed Erlang node.

### Description

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 a 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.

### Exports

erl_call <options>

Starts/calls Erlang.

Each option flag is described below with its name, type, and meaning.

-a [Mod [Fun [Args]]]]

  (Optional.) Applies the specified function and returns the result. Mod must be specified. However, start and [] are assumed for unspecified Fun and Args, respectively. Args is to be in the same format as for erlang:apply/3 in ERTS.

  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.

-c Cookie

  (Optional.) Use this option to specify a certain cookie. If no cookie is specified, the ~/.erlang.cookie file is read and its content is used as cookie. The Erlang node we want to communicate with must have the same cookie.

-d

  (Optional.) Debug mode. This causes all I/O to be output to the ~/.erl_call.out.Nodename file, where Nodename is 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.

-h HiddenName

  (Optional.) Specifies the name of the hidden node that erl_call represents.

-m

  (Optional.) Reads an Erlang module from stdin and compiles it.

-n Node

  (One of -n, -name, -sname is required.) Has the same meaning as -name and can still be used for backward compatibility reasons.

-name Node

  (One of -n, -name, -sname is required.) Node is the name of the node to be started or communicated with. It is assumed that Node is started with erl -name, which means that fully qualified long node names are used. If option -s is specified, an Erlang node will (if necessary) be started with erl -name.

-q

  (Optional.) Halts the Erlang node specified with switch -n. This switch overrides switch -s.

-r

  (Optional.) Generates a random name of the hidden node that erl_call represents.

-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, -sname is required.) Node is the name of the node to be started or communicated with. It is assumed that Node is started with erl -sname, which means that short node names are used. If option -s is specified, an Erlang node is started (if necessary) with erl -sname.

-v

  (Optional.) Prints a lot of verbose information. This is only useful for the developer and maintainer of erl_call.

-x ErlScript

  (Optional.) Specifies another name of the Erlang startup script to be used. If not specified, the standard erl startup script is used.

### 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>,
                      []}]