[erlang-questions] How to start an erlang applications from the command line non-interactively?
Tue May 6 13:13:04 CEST 2008
You are correct, it does depend upon the shell. I did not see you
mentioning this is the original email. That is why I asked.
I use rc (see http://swtch.com/plan9port/man/man1/rc.html or if you are
On Tue, 2008-05-06 at 10:35 +0200, Hynek Vychodil wrote:
> 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
> On Tue, May 6, 2008 at 7:08 AM, Bengt Kleberg
> <> wrote:
> 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).
> On Mon, 2008-05-05 at 17:54 -0400, Jarrod Roberson wrote:
> > On Mon, May 5, 2008 at 5:36 PM, Edwin Fine
> > <> 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
> > syntax should be.
> > This can be nasty to get right. It depends on how
> the command
> > line
> > interprets characters like single quote and double
> > 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
> > 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)), %
> > 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,
> > 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
> > http://www.erlang.org/mailman/listinfo/erlang-questions
> erlang-questions mailing list
> --Hynek (Pichi) Vychodil
More information about the erlang-questions