[erlang-questions] Passing arguments to erlang from the command line
Andy Khan
andyk@REDACTED
Sat Nov 18 00:01:11 CET 2006
Hi,
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@REDACTED
I get the following output:
=ERROR REPORT==== 17-Nov-2006::16:55:37 ===
Error in process <0.34.0> on node 'ping@REDACTED' with exit value:
{badarg,[{pingpong,ping,2}]}
However, if I first start the erlang shell and then invoke the start_ping
method, everying works fine:
>erl -sname ping
Eshell V5.5.2 (abort with ^G)
(ping@REDACTED)1> pingpong:start_ping(pong@REDACTED).
I must be missing something about passing arguments from the command line
(I've shown my hacked about version of the ping code below). Can anybody
help?
Regards
Andy
ping(N, Pong_Node) ->
{pong, Pong_Node} ! {ping, self()},
io:format("ping waiting for input~n", []),
receive
pong ->
io:format("Ping received pong~n", [])
end,
ping(N - 1, Pong_Node).
start_ping(Pong_Node) ->
spawn(pingpong, ping, [3, Pong_Node]).
More information about the erlang-questions
mailing list