escript

escript

Command

escript

Command summary

Erlang scripting support

Description

escript provides support for running short Erlang programs without having to compile them first, and an easy way to retrieve the command-line arguments.

Exports

script-name script-arg1 script-arg2...escript escript-flags script-name script-arg1 script-arg2...

escript runs a script written in Erlang.

Example:

$ chmod u+x factorial
$ cat factorial
#!/usr/bin/env escript
%% -*- erlang -*-
%%! -smp enable -sname factorial -mnesia debug verbose
main([String]) ->
    try
        N = list_to_integer(String),
        F = fac(N),
        io:format("factorial ~w = ~w\n", [N,F])
    catch
        _:_ ->
            usage()
    end;
main(_) ->
    usage().

usage() ->