Loading application variables
Sun Jun 11 14:22:44 CEST 2006
Den 2006-06-11 14:06:50 skrev Pupeno <>:
> On Sun, 2006-06-11 at 14:02 +0200, Ulf Wiger wrote:
>> I don't know if there's a standard function for loading the .config
>> but you can read and parse a .config file with
>> file:consult("miselfu.config"), and you can set environment variables
>> application:set_env(AppName, Key, Value).
> So, you don't normally work that way ? Opening up a shell on Emacs,
> running the application and re-loading code as it is modified ?
Well, you can also set environment variables via the command line, e.g.
erl -miselfu echoTCPPort 7 ...
but in order for them to actually take, you also need to load the miselfu
application, using application:load(miselfu). If your variables are
defined in a .config file, I thought it would be easier to write a small
erlang function that reads it and sets them appropriately. It can be done
in less than 10 lines of code.
I personally try to use builder in situations like that. It builds a bash
script that loads all given applications, but doesn't start them (except
the mandatory kernel and stdlib), essentially so that one could fire up an
erlang shell, with the code path and all the environment variables set,
and then do initialization or debugging from the shell.
More information about the erlang-questions