如何从脚本在 iex 中运行命令?

时间:2021-05-10 13:29:57

标签: bash shell elixir

我正在尝试编写一个简单的脚本来启动 IEX 的不同节点,每个节点都有自己的名字,并希望这些节点执行 de Node.ping :node_name@hostname 但我没有找到任何东西。

这是我目前的脚本:

#!/bin/bash

#Opens 3 clients

gnome-terminal  --command="bash -c 'iex --sname client1; $SHELL'"
gnome-terminal  --command="bash -c 'iex --sname client2; $SHELL'"
gnome-terminal  --command="bash -c 'iex --sname client3; $SHELL'"

#Opens de server
gnome-terminal  --command="bash -c 'iex --sname server; $SHELL'"

1 个答案:

答案 0 :(得分:0)

不能将命令“管道”到 iex 或以任何其他方式将其发送到正在运行的实例,但幸运的是,可以利用 .iex.exs 文件。

创建一个目录,在其中创建一个包含您想要的任何内容的 .iex.exs 并在其中运行您的脚本。


请注意,需要先调用 Node.connect/1 才能使 Node.ping/1 成功。