I have use erlang 21 version. When call "erl", it will run user's .erlang file for loading library's ebin file.
When running the following script by escript, it will not call.
#!/usr/bin/env escript
%% -*- erlang -*-
%%! -sname factorial -mnesia debug verbose
main([String]) ->
try
% io:format("~p",[lager_app:module_info()]),
io:format("aaaa"),
N = list_to_integer(String),
F = fac(N),
io:format("factorial ~w = ~w\n", [N,F])
catch
_:_ ->
usage()
end;
main(_) ->
usage().
usage() ->
io:format("aaaa\n~p",[lager_app:module_info()]),
io:format("usage: factorial integer\n"),
halt(1).
fac(0) -> 1;
fac(N) -> N * fac(N-1).
The error message is as follows:
yuchen@chenyu-Vostro-5468:~/a$ ./factorial
escript: exception error: undefined function lager_app:module_info/0