小编Jua*_*rez的帖子

运行N Erlang节点并使用bash脚本在每个节点内执行一行

TL; DR:如何向bash启动的程序发送一行(并可能在后台运行)?

你好!我已经尝试了很多来自那里的解决方案,但我无法将它们全部组合成一个可行的解决方案.

我想创建一个运行N Erlang节点的bash脚本,如:

for i in {1..N}:
    erl -name server$i@127.0.0.1 -setcookie secret
Run Code Online (Sandbox Code Playgroud)

我希望他们通过ping另一个节点来"连接"它们.为此,我们可以这样做:

erl -name some_server@127.0.0.1 -setcookie secret
(inside erlang)> net_adm:ping('another_server@127.0.0.1').
Run Code Online (Sandbox Code Playgroud)

但是,即使在单个节点上进行尝试,我也无法将这两者结合起来.

我试过了:

echo "net_adm:ping('another_server@127.0.0.1')." > erlang_command
cat erlang_command - | erl -name some_server@127.0.0.1 -setcookie secret

(i've had partial success with this one, i can run it manually but i couldn't make it to work to run in the background or in another terminal)
Run Code Online (Sandbox Code Playgroud)

要么

xterm -e "echo \"net_adm:ping('another_server@127.0.0.1').\"; cat erlang_command - | erl -name some_server@127.0.0.1 -setcookie secret" …
Run Code Online (Sandbox Code Playgroud)

linux bash shell erlang nodes

0
推荐指数
1
解决办法
46
查看次数

标签 统计

bash ×1

erlang ×1

linux ×1

nodes ×1

shell ×1