我的第一个escript

  1 #!/usr/bin/env escript

  2 %% -*- erlang -*-

  3 -mode(compile).

  4 main([]) ->

  5     io:format("This is my first escript.~n");

  6 

  7 main([Arg1]) ->

  8     io:format("This is my first escript Arg1=~p~n", [Arg1]);

  9 main([Arg1,Arg2]) ->

 10     io:format("This is my first escript {Arg1,Arg2}=~p~n", [{Arg1,Arg2}]);

 11 main(Arg1) ->

 12     io:format("This is my first escript Arg1=~p~n", [Arg1]).                                                                                      

 13 

以后的脚本测试可以这样写

 

jason@jason-lxw:~/soft/rabbitmq$ ./test 22

This is my first escript Arg1="22"

jason@jason-lxw:~/soft/rabbitmq$ ./test 22 32

This is my first escript {Arg1,Arg2}={"22","32"}

jason@jason-lxw:~/soft/rabbitmq$ ./test 22 3244

This is my first escript {Arg1,Arg2}={"22","3244"}

jason@jason-lxw:~/soft/rabbitmq$ ./test 22 3244 sss

This is my first escript Arg1=["22","3244","sss"]

jason@jason-lxw:~/soft/rabbitmq$ 

 

你可能感兴趣的:(script)