(以下摘抄自Programming Erlang第六章)

Using escript you can run your programs directly as scripts—there’s no need to compile them first.

Warning: escript is included in Erlang versions R11B-4 and onward. If you have an earlier version of Erlang, then you should upgrade to the latest version of Erlang.

To run hello as an escript, we create the following file:

#!/usr/bin/env escript
main(_) -> io:format("Hello world\n" ).

On a Unix system,we can run this immediately and without compilation as follows:

$ chmod u+x hello
$ ./hello
Hello world
$