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

db <>
Thu Feb 28 03:57:33 CET 2008


How do you run escript with parameters?

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

[ scripts]$ ./rpc_test main   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.html>


More information about the erlang-questions mailing list