[erlang-questions] [Erlang-Q] What does Ctrl+G do for the Eshell?

Anders Ramsell anders@REDACTED
Tue Oct 4 00:13:09 CEST 2011

Barco You wrote:
> Hello Erlangers,
> When starting a erl shell, we will see a printout as:
> Eshell V5.8.4  (abort with ^G)
> then, I tried to press Ctrl+G and got:
> User switch command
>   -->  ls
> Unknown command
>   -->  q().
> Unknown command
>   -->
> I can do nothing with the prompt "-->". How to quit from it? and
> what's "Ctrl+G" used for?
The words "abort with ^G" are in fact hiding an extremely useful
function called JCL (job control mode) [1]. I overlooked this
function for years.  Now I use it on a near daily basis and just
love it.

[1] http://www.erlang.org/doc/man/shell.html

Assume you have an Erlang node named 'server@REDACTED' running as a
service/daemon on your system. Wouldn't it be great if you could
run interactive commands on this node just like you do in a
shell? JCL let's you do that with ease.

Start up a new shell 'client@REDACTED' and hit ctrl-G to enter JCL.
Now start a remote shell to 'server@REDACTED'.

| (client@REDACTED)1>
| User switch command
|  --> r server@REDACTED
|  --> j
|    1* {shell,start,[init]}
|    2  {server@REDACTED,shell,start,[]}

You now have a local shell with id=1 and a remote shell with
id=2. Connect to the remote shell:

|  --> c 2
| (server@REDACTED)1>

Now you have a shell on the server node where you can run any
command you want. This means you can call any exported function
in all modules loaded on the server. That kind of interaction
with a running system can be invaluable when trying to figure out
why it doesn't behave quite the way you planned.

Now of course there is a backside to the story. Doing something
wrong may cause your system to crash. So hey - let's be careful
out there.


More information about the erlang-questions mailing list