开发者

Automate Erlang shell nodes with unix batch

开发者 https://www.devze.com 2023-04-12 10:18 出处:网络
I can run many erlang nodes from batch file. But, can i pass some ar开发者_运维问答guments to erl that cause it to execute some commands?If you wish to start a node, and for example start an erlang ap

I can run many erlang nodes from batch file. But, can i pass some ar开发者_运维问答guments 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号