我如何从脚本在 iex 中执行 运行 命令?
How can i run commands in iex from a script?
我正在尝试编写一个简单的脚本来启动 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'"
不能将命令“管道”到 iex
或以任何其他方式将其发送到 运行ning 实例,但幸运的是,可以利用 .iex.exs
文件.
创建一个目录,在其中创建一个包含您想要的任何内容的 .iex.exs
并从中创建 运行 您的脚本。
请注意,需要先调用Node.connect/1
for Node.ping/1
才能成功。
我正在尝试编写一个简单的脚本来启动 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'"
不能将命令“管道”到 iex
或以任何其他方式将其发送到 运行ning 实例,但幸运的是,可以利用 .iex.exs
文件.
创建一个目录,在其中创建一个包含您想要的任何内容的 .iex.exs
并从中创建 运行 您的脚本。
请注意,需要先调用Node.connect/1
for Node.ping/1
才能成功。