[erlang-questions] run escript with parameters passed via os cmd line

db masterofquestions@REDACTED
Thu Feb 28 03:57:33 CET 2008


How do you run escript with parameters?

[db@REDACTED scripts]$ ./rpc_test nonode@REDACTED  erlang_test test
usage: You need to provide valid Node Name & Module Name & Args

[db@REDACTED scripts]$ ./rpc_test main nonode@REDACTED  erlang_test test
usage: You need to provide valid Node Name & Module Name & Args

Here is my escript called rpc_test:

#!/usr/bin/env escript
%% -*- erlang -*-
%-mode(compile).

-export([main/3, main/1, main/2]).
%-export([main/3]).

main(Node,Module,Args) ->
    try
        rpc:call(Node, Module, main, Args)

    catch
        _:_ ->
            usage1()
    end.

main(_) ->
    usage().

main(_,_) ->
    usage().

usage() ->
    io:format("usage: You need to provide valid Node Name & Module Name &
Args\n"),
    halt(1).

usage1() ->
    io:format("usage1: RPC Call Problem\n"),
    halt(1).


-- 
rk

That which we persist in doing becomes easier for us to do; not that the
nature of the thing itself is changed, but that our power to do is
increased.
-Ralph Waldo Emerson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080227/cecd0777/attachment.htm>


More information about the erlang-questions mailing list