【发布时间】:2016-10-24 01:05:34
【问题描述】:
Elixir 初学者在这里!我正在尝试基于配置文件生成 bash 脚本。当我迭代配置并打印我生成的字符串时,一切都很好。但是,当我尝试连接或附加到列表时,我什么也得不到!
def generate_post_destroy_content(node_config) do
hosts = create_post_destroy_string(:vmname, node_config)
ips = create_post_destroy_string(:ip, node_config)
content = "#!/bin/bash\n\n#{hosts}\n\n#{ips}"
IO.puts content
end
def create_post_destroy_string(key, node_config) do
# content = ""
content = []
for address <- node_config, do:
# content = content <> "ssh-keygen -f ~/.ssh/known_hosts -R #{address[key]}"]
content = content ++ ["ssh-keygen -f ~/.ssh/known_hosts -R # {address[key]}"]
# IO.puts ["ssh-keygen -f ~/.ssh/known_hosts -R #{address[key]}"]
content = Enum.join(content, "\n")
content
end
我的输出
#!/bin/bash
=========END=========
【问题讨论】:
标签: elixir