TL; DR:如何将行发送到Bash启动的程序(并可能在后台运行)?
你好! 我从那里尝试了很多解决方案,但是我无法将它们全部组合成一个可行的解决方案。
我想制作一个运行N Erlang节点的bash脚本,例如:
for i in {1..N}:
erl -name server$i@127.0.0.1 -setcookie secret
我希望他们通过ping另一个节点来“连接”它们。 为此,我们可以这样做:
erl -name some_server@127.0.0.1 -setcookie secret
(inside erlang)> net_adm:ping('another_server@127.0.0.1').
但是,即使在单个节点上尝试,我也无法将两者结合起来。
我试过了:
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)
要么
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"
或其他技巧,例如:
echo "net_adm:ping('another_server@127.0.0.1')." | erl -name some_server@127.0.0.1 -setcookie secret
-----
echo "net_adm:ping('another_server@127.0.0.1')." > /dev/stdin
erl -name some_server@127.0.0.1 -setcookie secret
-----
Some uses of nohup and & (can't remember these exactly, but got a similar experience)
nohup erl -name some_server@127.0.0.1 -setcookie secret &
但是这些都不起作用或不能正确执行ping并完成我的erlang节点,我想继续运行。 我想念什么? 谢谢!