[erlang-questions] escript and application environment
Wed Jan 28 10:42:53 CET 2015
Le 28 janv. 2015 à 07:20, Nathan Fiedler <nathanfiedler@REDACTED> a écrit :
> 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.
Replace "application:load(myapp)" by "ok = application:load(myapp)" and run the script again. I am pretty sure the application didn't even get loaded.
More information about the erlang-questions