escript provides support for running short Erlang programs
without having to compile them first and an easy way to retrieve
the command line arguments. escript runs a script written in
Erlang. Here follows an example. $ cat factorial #!/usr/bin/env
escript %% -*- erlang -*- %%! -smp enable -sname factorial
-mnesia debug verbose main([String]) -> try \011N =
list_to_integer(String), \011F = fac(N),
\011io:format("factorial ~w = ~w\ ", [N,F]) catch \011_:_ ->
\011 usage() end; main(_) -> usage(). usage() ->
io:format("usage: factorial integer\ "), halt(1). fac(0) -> 1;
fac(N) -> N * fac(N-1). $ factorial 5 factorial 5 = 120 $
factorial usage: factorial integer $ factorial five usage:
factorial integer The header of the Erlang script in the example
differs from a normal Erlang module. The first line is intended
to be the interpreter line, which invokes escript. However if
you invoke the escript like this $ escript factorial 5 the
contents of the first line does not matter, but it cannot
contain Erlang code as it