Forrest logo
back to the erlc tool


erl: Compile and run sequential Erlang program as a common script and then exit.
$ erlc ${files} && erl -noshell '${mymodule:myfunction(arguments)}, init:stop().'
try on your machine

This command is a shell command that can be used to compile Erlang files using the erlc compiler and then run an Erlang program using the erl command.

Let's break it down:

  1. erlc ${files}: This part of the command compiles the Erlang files specified by the ${files} variable. ${files} is a placeholder for the actual file names you want to compile. For example, if ${files} is myfile.erl, then this command will compile myfile.erl into myfile.beam, which is the compiled equivalent of the Erlang source file.

  2. &&: This is a command chaining operator that allows you to run multiple commands consecutively. In this case, it ensures that the second command (erl) will only run if the compilation (erlc) was successful.

  3. erl -noshell '${mymodule:myfunction(arguments)}, init:stop().': This part of the command runs the Erlang runtime system (erl) with the following options:

    • -noshell: This option starts Erlang without the interactive shell.
    • '${mymodule:myfunction(arguments)}, init:stop().': This is the actual Erlang code that will be executed. It is enclosed in single quotes to represent a string in the shell command. This code consists of a single function call mymodule:myfunction(arguments) followed by init:stop(). When the specified function (myfunction) is executed, it will perform its operations, and then the init:stop() call will terminate the Erlang runtime system.

To summarize, this command compiles Erlang files specified by ${files} and if the compilation is successful, it runs an Erlang program that invokes a specific function (myfunction) in a designated module (mymodule) with the specified arguments. Once the function completes its execution, the Erlang runtime system is terminated.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the erlc tool