Erlang Access Remote Shell console

Source: Internet
Author: User
Tags setcookie

The Erlang Shell is an interface program that users interact with the Erlang runtime system. In fact, the Erlang VM runs without any shell, as long as the parameter detached is added at startup to get out of the terminal. - detachedStarts the Erlang runtime system detached from the system console. Useful for running daemons and backgrounds processes. Implies-noinput. In fact, detached is equivalent to Noshell plus noinput. # Erl- detached-emu_args
Executing:/home/erl/lib/erlang/erts-5.10.3/bin/beam/home/erl/lib/erlang/erts-5.10.3/bin/beam---root/home/erl/ Lib/erlang-progname Erl---home/root-- -noshell-noinput
Also, it is important to note that Windows does not directly support detached, but instead runs in the background as a service, seeErlsrv
Here are a few ways to access the remote shell console from Erlang. Job (JCL) mode You can see the menu of the job control mode (JCL mode) by pressing the ^G key in the Erlang shell. In the menu, there isoption allows us to connect to a remote shell. Run a node with detached first 1:# erl-name [email protected]-setcookie 123456-detachedCheck if this Erlang process is running
# Ps-ef | grep beamroot 20672 1 0 01:32? 00:00:00/home/erl/lib/erlang/erts-5.10.3/bin/beam---Root/home/erl/lib/erlang-progname erl ---home/root---name [email protected]-setcookie 123456-noshell-noinput Start another node 2 and connect to Node 1
# Erl-name [email protected] -setcookie 123456
Erlang r16b02 (erts-5.10.3) [source] [64-bit] [async-threads:10] [hipe] [Kernel-poll:false]
Eshell V5.10.3 (abort with ^g)
([email protected]) 1>
User Switch Command
-H
c [NN]-connect to Job
I [NN]-interrupt job
K [nn]-kill job
J-list All Jobs
s [Shell]-start local shell
R [node [Shell]]-Start remote shell
Q-quit Erlang
? | H-this message
-R '[email protected]
-J
1 {Shell,start,[init]}
"[email protected]', shell,start,[]}
-C 2
Eshell V5.10.3 (abort with ^g)
([email protected]) 1>
Notice that you want to use Werl under Windows
After connecting to the remote shell, all of the terminal input parsing operations are done by the local shell, but the work of the evaluation is farthe process is completed.  The result output of the remote evaluation is all forwarded to the local shell. To exit the shell, press ^g to return to JCL mode.Terminal Input parsing operationis done locally, so exit the shell by ^g Qis safe. Eshell V5.10.3 (abort with ^g)
([email protected]) 1>
User Switch Command
-Q

Remsh ModeRemsh and JCL patterns are similar, but they are called in different ways. Using this mechanism, the JCL mode of allthe procedure can be bypassed, just start the shell as follows, for long names:
-remsh Nodestarts Erlang with a remote shell connected to Node.
starting node 2 in the following manner will directly access the Node 1 console:# erl-name [email protected] -setcookie 123456 -remsh [email protected]Erlang r16b02 (erts-5.10.3) [source] [64-bit] [async-threads:10] [hipe] [Kernel-poll:false]Eshell V5.10.3 (abort with ^g)( [email protected]) 1> node ().' [email protected] 'This approach is similar to JCL, where an Erlang node is also launched to access the remote shell

SSH ModeErlang comes with ssh, we can easily open SSH service, providing remote shell services externally. SSH needs to be opened crypto, if Erlang displays the following error, you can refer to this article. 1> Crypto:start (). * * Exception error:undefined function crypto:start/0to use this feature, you will usually need to have a key with remote access SSH permission, but here to quicklytest, you can do this:Node 1 starts the SSH service:
Eshell V5.10.3 (Abort with ^g) ([email protected]) 1> Ssh:start (). OK ([email protected]) 2> ssh: Daemon (8888, [{password, "12345"}]). {Ok,<0.57.0>}
You do not need to start the Erlang node locally, directly using SSH connection, enter the password set above, you can access the shell console of node 1.
# ssh-p 8888 [email protected] The authenticity of host ' [127.0.0.1]:8888 ([127.0.0.1]:8888) ' can ' t be established. RSA key fingerprint is ad:03:b4:6b:df:51:97:23:dc:47:cb:75:85:15:44:89. Is you sure want to continue connecting (yes/no)? Yes Warning:permanently added ' [127.0.0.1]:8888 ' (RSA) to the list of known hosts. [email protected] ' s Password:eshell V5.10.3 (abort with ^g) ([email protected]) 1>
This way, Erlangall shell operations are done at the remote node.

piping (pipe) modeWhen connecting to an Erlang node using pipelines (pipes), you do not need to start the local Erlang node like SSH. This method is rarely used, each time the output is called Fsync, if the output is too high, there will be a great loss of performance.

This is done by starting Erlang with Run_erl, which is equivalent to wrapping the Erlang process in ain the pipeline:# Mkdir/tmp/erl_log# Cd/home/erl/bin#./run_erl-daemon/tmp/erl_pipe/tmp/erl_log "Erl-name [email protected] -setcookie 123456"where daemon represents the next process run,/tmp/erl_pipe is the name of the pipeline file,/tmp/erl_log Specifies the log save folderthen use the To_erl program to connect the nodes:#./to_erl/tmp/erl_pipeAttaching To/tmp/erl_pipe (^d to exit)
( [email protected]) 1> node ().
‘[email protected]‘
Reference: Http://blog.csdn.net/mycwq/article/details/43850735https://s3.amazonaws.com/erlang-in-anger/text.v1.0.3.pdf

Erlang Access Remote Shell console

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.