[erlang-questions] escript and application environment

Nathan Fiedler nathanfiedler@REDACTED
Wed Jan 28 15:02:45 CET 2015


Oh yeah, I need a myapp.app file, duh.

Thanks for addressing my question, dumb as it was.

n


On Wed, Jan 28, 2015 at 1:42 AM, Anthony Ramine <n.oxyde@REDACTED> wrote:
> 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([]) ->
>>    application:load(myapp),
>>    Results = application:get_all_env(myapp),
>>    io:format("results: ~p~n", [Results]),
>>    ok.
>>
>> 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.
>>
>> n
>
> 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.
>
> Regards.



More information about the erlang-questions mailing list