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)