> I'm playing with the pingpong example in the tutorial, and I'm trying to
> launch the ping process directly from the command line. When I run the
> program as follows:
>>erl -sname ping -run pingpong start_ping pong@bmt71
>From the erl man page:
-run Mod [Func [Arg1, Arg2, ...]] (init flag):
Makes init call the specified function. Func defaults to start.
If no arguments are provided, the function is assumed to be of
arity 0. Otherwise it is assumed to be of arity 1, taking the
list [Arg1, Arg2, ...] as argument. All arguments are passed as
strings. See init(3).
So pong@bmt71 ends up being a string.
How about using -eval "pingpong:start_ping(pong@bmt71)"
I wrote a small script to show you why this does not work
io:format("arg = ~p~n", [Arg]).
I will first invoke the script from the erl shell and then from the
command line with the run option as you do.
---------- from the command shell ------------
arg = martin@logan
---------- from the command line ------------
martinjlogan@core:~$ erl -run test test martin@logan
Erlang (BEAM) emulator version 5.4.12 [source] [hipe]
arg = ["martin@logan"]
Eshell V5.4.12 (abort with ^G)
See the problem? :)
From: [hidden email] [mailto:[hidden email]] On Behalf Of Andy Khan
Sent: Friday, November 17, 2006 5:01 PM
To: [hidden email] Subject: [erlang-questions] Passing arguments to erlang from the command
I'm playing with the pingpong example in the tutorial, and I'm trying to
launch the ping process directly from the command line. When I run the
program as follows: