[erlang-questions] How to start an erlang applications from the command line non-interactively?

Hynek Vychodil vychodil.hynek@REDACTED
Tue May 6 10:35:01 CEST 2008


There is not difference between ' and " from called program point of view.
Both strings are passed as one argv zero byte terminated string. Program
can't get knowledge which sort of quotes was used. There is only difference
from shell's point of view. What sort of shell you use?

On Tue, May 6, 2008 at 7:08 AM, Bengt Kleberg <bengt.kleberg@REDACTED>
wrote:

> Greetings,
>
> Are you sure about
> erl -s foo Jarrod 12345 "This is a string"
> resulting in
> Name: 'Jarrod', Int: 12345, Str: "This is a string"
> ?
>
> On my machine I have to use
> erl -s foo Jarrod 12345 'This is a string'
>
> Note the ' instead of ".
>
>
> When choosing between -s and -run, IMHO -run is better integrated with
> unix than -s (C does not have atoms).
>
>
> bengt
>
> On Mon, 2008-05-05 at 17:54 -0400, Jarrod Roberson wrote:
> >
> >
> > On Mon, May 5, 2008 at 5:36 PM, Edwin Fine
> > <erlang-questions_efine@REDACTED> wrote:
> >         > I have a function start(Port, Htdocs) that I want to call
> >         with 8888,
> >         > "C:/htdocs" and I can't figure out what the appropriate
> >         syntax should be.
> >
> >         This can be nasty to get right. It depends on how the command
> >         line
> >         interprets characters like single quote and double quote.
> >         It also depends on whether you use -s or -run.
> >
> >         -s interprets all function arguments as atoms, so your program
> >         will
> >         get all the values as atoms. You will usually need to write a
> >         special
> >         MFA to convert the atoms to the actual types of the parameters
> >         desired. Note that all arguments get passed in a single list
> >         when
> >         called like this (see start_cmd_line/3).
> >
> >         -run interprets all function arguments as strings, so your
> >         program
> >         will get all the values as string. You will often have to
> >         write a
> >         special MFA to convert the strings to the actual types of the
> >         parameters desired.
> >
> >         For example:
> >
> >         -module(foo).
> >         -export([start_cmd_line/1, start/3]).
> >
> >         start_cmd_line([NameAtom, IntValue, StrValue]) when
> >         is_atom(NameAtom),
> >         is_atom(IntValue), is_atom(StrValue) ->
> >            Name = NameAtom, % Not really necessary because NameAtom is
> >         already an atom
> >            Int = list_to_integer(atom_to_list(IntValue)), % Could
> >         throw an exception
> >            Str = atom_to_list(StrValue),
> >            start(Name, Int, Str).
> >
> >         start(Name, Int, Str) ->
> >            io:format("Name: ~p, Int: ~p, Str: ~p~n", [Name, Int,
> >         Str]),
> >           % Etc
> >           ok.
> >
> >         If you started the above by
> >
> >         erl -s foo Jarrod 12345 "This is a string"
> >
> >         you would get an output something like this:
> >         Erlang (BEAM) emulator version 5.6.2 [source] [64-bit] [smp:4]
> >         [async-threads:0] [hipe] [kernel-poll:false]
> >
> >         Name: 'Jarrod', Int: 12345, Str: "This is a string"
> >         Eshell V5.6.2  (abort with ^G)
> >         1>
> >
> >         Hope this helps.
> >
> > thanks that clears things up greatly.
> >
> >
> > _______________________________________________
> > erlang-questions mailing list
> > erlang-questions@REDACTED
> > http://www.erlang.org/mailman/listinfo/erlang-questions
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>



-- 
--Hynek (Pichi) Vychodil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080506/e577bec8/attachment.htm>


More information about the erlang-questions mailing list