Passing argument from the command line

Jens Peder Terjesen (ETO) Jens.Peder.Terjesen@REDACTED
Fri Nov 3 16:36:57 CET 2000


Hi.

This seems to work (dialog with Unix shell):

{etojpt_impro_baseline}: adp {687} $ erl -boot start_clean -sname testnode <<EOF 
> io:format("test~n").
> EOF
Eshell V4.9.1.1  (abort with ^G)
(testnode@REDACTED)1> test
ok
(testnode@REDACTED)2> ** Terminating erlang **
{etojpt_impro_baseline}: adp {688} $ 

Or perhaps easier in a shell script (attached).
Invoke as: cmdlinetest <string to print>

Jens



-----Original Message-----
From: Mickael Remond [mailto:mickael.remond@REDACTED]
Sent: 12. oktober 2000 14:23
To: erlang-questions@REDACTED
Subject: Passing argument from the command line



It seems that the argument of the Erlang command line are always list of
atoms...
Is it right or am I missing something ?

In fact, whith this fact you need to design your functions specifically if you
want them to be called directly from the command line and from the Erlang
shell.

For example: I was building a makefile to transform .ehtml into .html files.

The command I am using is:

 erl -s ehtml file index -s init stop

And it does not work from the command line.



I have changed the following code in ehtml.erl:

file(F) when list(F) ->
    file(F ++ ".ehtml", F ++ ".html").

into:

% Called from the command line
file([F|Empty]) when atom(F), Empty==[] ->
    file(atom_to_list(F));
% Called from the Erlang Shell
file(F) when list(F) ->
    file(F ++ ".ehtml", F ++ ".html").

And the command line is working.

Am I missing something or must I make sure that all function that need to be
command line compliant should accept list of atoms ?

Thank you for help.

-- 
Mickaël Rémond

-------------- next part --------------
A non-text attachment was scrubbed...
Name: cmdlinetest
Type: application/octet-stream
Size: 79 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20001103/86c87d60/attachment.obj>


More information about the erlang-questions mailing list