S
S
Sergey2014-02-21 13:56:46
Erlang
Sergey, 2014-02-21 13:56:46

Erlang: how to execute code on a remote node?

I want to execute code on a remote node.
I do this:
erl -sname console -remsh "[email protected]`hostname`" -eval "test:test()."
What is wrong, because test:test() is executed on the current node, but I need it on a remote one.
And what command will disconnect from the remote node?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrew, 2014-02-21
@begemot_sun

www.erlang.org/doc/man/rpc.html#call-4 to execute functions on another node.
www.erlang.org/doc/man/erlang.html#disconnect_node-1 to disconnect, also called via rpc:call on the [email protected]`hostname` node.
well, you can complete everything with init:stop() to close the interpreter.
something like this:

erl -sname console -remsh "[email protected]`hostname`" -eval "rpc:call('[email protected]`hostname`', test, test, []), rpc:call('[email protected]`hostname`', erlang, disconnect_node, [node()]), init:stop()."

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question