[erlang-questions] Passing command line options to erlang programs

Bengt Kleberg bengt.kleberg@REDACTED
Tue Oct 26 08:52:43 CEST 2010


Greetings,

Please look at the erl manual page: 
http://erlang.org/doc/man/erl.html

There you will find that all flags (arguments with - first) are for the
Erlang part of the runtime system.

However, there are -extra and -- which both may be what you are looking
for.


bengt


On Tue, 2010-10-26 at 07:43 +0200, Muharem Hrnjadovic wrote:
> Hello,
> 
> I am fairly new to erlang, so please forgive me if this is a stupid
> question :-)
> 
> I am trying to pass command line options to the following erlang program:
> {{{
> -module(demo).
> -export([main/1]).
> 
> main(Args) -> io:format("~p~n", [Args]).
> }}}
> 
> When only passing command line *arguments* everything works as expected:
> 
> {{{
> $ erl -noshell -s demo main a b c -s init stop
> [a,b,c]
> }}}
> 
> But when passing command line *options* things break
> 
> {{{
> $ erl -noshell -s demo main a -b c -s init stop
> [a]
> $ erl -noshell -s demo main -a b c -s init stop
> {"init terminating in
> do_boot",{undef,[{demo,main,[]},{init,start_it,1},{init,start_em,1}]}}
> 
> Crash dump was written to: erl_crash.dump
> init terminating in do_boot ()
> }}}
> 
> Is there another way to sneak options past erl? Or is the code above
> broken in some other way?
> If no, then maybe erl needs an option passing/escape mechanism like e.g.
> gcc's "-Wl" ..?
> 
> When using an escript file BTW things works as one would expect.
> 
> Best regards/Mit freundlichen Grüßen
> 



More information about the erlang-questions mailing list