문제

I can run many erlang nodes from batch file. But, can i pass some arguments to erl that cause it to execute some commands?

도움이 되었습니까?

해결책

If you wish to start a node, and for example start an erlang application, or run a few lines for the start up of the node you can run the erl command the following way

erl -eval "application:start(my_app)"

or starting the node with several commands

erl -eval "Res = my_first_module:my_start_fun(MyArg),
           my_log:log(Res),
           another_module:another_fun(Res)"

the same has above but putting the node into a background process

erl -sname nodename 
    -setcookie nodecookie 
    -eval "Res = my_first_module:my_start_fun(MyArg),
           my_log:log(Res), 
           another_module:another_fun(Res)" 
    -detached

But if you want to run erlang in a more "scriptwise" way I do suggest you look into escript and the following question like D.Nibon suggested

다른 팁

Yes. You can. If you ask more specific, i will get you a more specific answer, if i'm able to. This seems like a more "erlang" question than a "bash" question.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top