Passing argument from the command line

Jens Peder Terjesen (ETO) <>
Fri Nov 3 16:36:57 CET 2000


This seems to work (dialog with Unix shell):

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

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


-----Original Message-----
From: Mickael Remond [mailto:]
Sent: 12. oktober 2000 14:23
Subject: Passing argument from the command line

It seems that the argument of the Erlang command line are always list of
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

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").


% Called from the command line
file([F|Empty]) when atom(F), Empty==[] ->
% 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: <>

More information about the erlang-questions mailing list