[erlang-questions] compile several modules from shell

Joe Armstrong <>
Tue Dec 1 14:23:45 CET 2009

What you are really asking is "how can I change the default commands
in the shell?"

This is what the module user_default.erl is for.

If you define a module called user_default compile it and put it in
your erlang path
then the commands in user default will be added to your shell and can
be called without giving
the prefix "user_default"

So to redefine the behaviour of c(file) we do this:


    c(A) when is_atom(A) ->  c:c(A);
    c(L) when is_list(L) ->  [c:c(I) || I <- L].

Compile this add it to your path and you're away:

> c(spy).
./spy.erl:22: Warning: variable 'Pid' is unused
> c([spy,elib1_spy]).
./spy.erl:22: Warning: variable 'Pid' is unused

if you want to send the code to remote nodes or whatever, this is the
place to do it, if you want to do
this from the shell.

To see how the current commands are implement look at the code in something like


Modesty prevents me from plugging an Erlang book where this is described :-)


On Tue, Dec 1, 2009 at 11:23 AM, Roberto Ostinelli
<> wrote:
> dear all,
> as many of us are, i often use multiple nodes in my erlang
> applications. during development, all nodes reside on the same
> machine.
> fact is, when i compile a module on one of the nodes, the other nodes
> are erraticly updated with the freshly compiled module, even if it is
> not running [probably a cache of the loaded modules, i guess]. what i
> experience is that some nodes get updated, some others not, in a way i
> cannot figure a common pattern.
> therefore, the only thing i have figured out to do is to compile the
> module on the shell of all the running nodes, issuing the
> c(module_to_compile) command [which forces the refresh of the loaded
> modules].
> however, when i have to compile many modules, i find myself compiling
> all of them manually, repeatedly: c(module_1), c(module_2), .... on
> every node. this is annoying.
> my questions are:
> 1. is there another way to force the refresh [if this is the issue] so
> that, when i use a bash script to compile all modules all the nodes on
> the machine use the freshly compiled code?
> 2. otherwise, is ther a way to issue a shell compile on multiple
> modules [such as c(*) or such]?
> thank you,
> r.
> ________________________________________________________________
> erlang-questions mailing list. See http://www.erlang.org/faq.html
> erlang-questions (at) erlang.org

More information about the erlang-questions mailing list