Last week, I wrote, compiled and run our first erlang program.

Take a look at Erlang setup and hello world.

To do that, I had to launch the erlang shell.

If I want to launch the hello.erl program from the bash shell, erlang provides to switches: -s and -run.

for example, to launch the hello world program I can type the following command directly in the bash:

$ erl -run hello hello_world

and the result will be

Erlang R15B01 (erts-5.9.1)

[64-bit] [async-threads:0] [kernel-poll:false]

hello, world
Eshell V5.9.1 (abort with ^G)

1>

erlang-logo-darkback

As you can see, after the function hello_world has been run, the erlang shell is active. If you want to come back to the bash you can add the options -run init stop

 

$ erl -run hello hello_world -run init stop

and the result will be:

Erlang R15B01 (erts-5.9.1)

[64-bit] [async-threads:0] [kernel-poll:false]

hello, world
Eshell V5.9.1 (abort with ^G)

$

Gg1