[erlang-questions] escript and application environment

Nathan Fiedler nathanfiedler@REDACTED
Wed Jan 28 07:20:28 CET 2015

Web search yields many irrelevant results and the man pages for erl,
escript, app, and application make no mention of this, that I can see.
Let's say I have a simple escript as shown below.

#!/usr/bin/env escript
%%! -emu_args -myapp val var

main([]) ->
    Results = application:get_all_env(myapp),
    io:format("results: ~p~n", [Results]),

Running this yields:

$ ./myapp.escript
Executing: /usr/local/Cellar/erlang/17.4/lib/erlang/erts-6.3/bin/beam.smp
/usr/local/Cellar/erlang/17.4/lib/erlang/erts-6.3/bin/beam.smp -B --
-root /usr/local/Cellar/erlang/17.4/lib/erlang -progname erl -- -home
/Users/nfiedler -- -boot start_clean -noshell -myapp val var -run
escript start -extra ./myapp.escript

results: []

Does anyone know why the val setting does not show up? In a full blown
application, everything is as expected, but why not in escript? Is
there another call I need to make to facilitate this functionality?

Thanks any help you can offer.


More information about the erlang-questions mailing list