newby: erl in a batch

Kent Boortz <>
Thu Jul 20 15:30:44 CEST 2000


> Id like to have erlang started in a batch, and execute, say
> cot2dot.erl:convert().
> 
> 1) should I create a start() function, and should cot2dot be a server
> behaviour?

You can start any function, has nothing to do with server behaviours.
Run "erl -man erl" or see

  http://www.erlang.org/documentation/erts-4.9.1/doc/html/erl.html

Look at the "-noinput" and "-noshell" flags. Note that you have to
explicitly terminate Erlang if you don't want it to stay up. Call
halt() in your program or from the command line

  % erl -noshell -s mymodule myfunction -s erlang halt

> 2) how can i read the arguments passed on the command line (argc,
> argv in C), so i can do xxx 1 2 3 if xxx is a batch doing erl
> -scot2dot $1 $2 $3 , and read 1 2 3?

You can read them with init:get_arguments() or
init:get_argument(Flag).  See

  http://www.erlang.org/documentation/lib/kernel-2.5/doc/html/init.html

Note that if you write "Erlang applications" you pass arguments a bit
different. You can use -config to point out a configuration file or
alter application data directly from the command line, by giving -Name
Par Value. See

  http://www.erlang.org/documentation/lib/kernel-2.5/doc/html/application.html

> 3) how can i improve any performance a load time, like suppressing
> the load of .erlang, and should i have the beam in the current dir,
> or where ?

The "load on demand" Erlang uses not in embedded mode should give
reasonable fast startup time, especially when the Erlang shell is not
started.

> are where could i find these things  in the doc ?

You can find some more information at

  http://www.erlang.org/documentation/doc/system_principles/part_frame.html

kent



More information about the erlang-questions mailing list