starting erlang app from command line

Anders Nygren anders.nygren@REDACTED
Sat Jul 29 01:12:55 CEST 2006


On 7/28/06, CyBerHigh <cyberhigh@REDACTED> wrote:
> I was wondering if it was possible to start an erlang app from the
> command line.  Like a simple shell script you would just put in the
> shebang and mark it as executable then run it.  However this doesn't
> seem to be possible with erlang.  Anything I write seems to have to be
> done from the erlang shell.  Are there any workarounds?

Hi
To execute an erlang function from the shell You can do
> erl -run Mod Fun [Arg1 [Arg2...]]

See 'erl -man erl' for details. That will start an Erlang shell and execute
Mod:Fun([Args]), but the shell will not terminate.

If You want it to terminate when it is finishedYou can do

> erl -run Mod Fun [Arg1 [Arg2...]] -run init stop

If You don't want the shell You can also add -noshell.

If You want to run Your erlang application as a server You can also take
a look at 'System Principles' and 'Embedded System' parts of the erlang
documentation.

Once upon a time there was something called escript that allowed You to
do what You asked for, but it disappeared some releases ago.

/Anders



More information about the erlang-questions mailing list