Search code examples
basherlangenvironment-variables

How to set an environment variable in escript or Erlang


Can I set an environment variable when executing an escript script so that the environment variable can be read by other applications executing in the same environment (so effectively is there an equivalent of bash command export available in escript or Erlang)?


Solution

  • A process cannot affect the environment of its parent or of its parent's other child processes.

    If you want to modify the environment for processes started by your script (via fork or something similar, although OP informs me this is not supported), there is probably something like setenv available.