2
处理由我通过Capistrano运行的命令触发的输入提示的正确方法是什么?在Capistrano处理输入提示的正确方法?
一个示例是我使用安装的iptables-persistent
软件包。尽管标记为--no-gui
,但仍然出现提示,要求我确认如何配置事物。
有没有办法通过命令行传递参数来避免这种提示?
处理由我通过Capistrano运行的命令触发的输入提示的正确方法是什么?在Capistrano处理输入提示的正确方法?
一个示例是我使用安装的iptables-persistent
软件包。尽管标记为--no-gui
,但仍然出现提示,要求我确认如何配置事物。
有没有办法通过命令行传递参数来避免这种提示?
我发现能够从实现这个非常有用的handle_command_with_input方法:
https://github.com/nesquena/cap-recipes/blob/master/lib/cap_recipes/tasks/utilities.rb
def handle_command_with_input(local_run_method, shell_command, input_query, response=nil)
send(local_run_method, shell_command, {:pty => true}) do |channel, stream, data|
if data =~ input_query
if response
logger.info "#{data} #{"*"*(rand(10)+5)}", channel[:host]
channel.send_data "#{response}\n"
else
logger.info data, channel[:host]
response = ::Capistrano::CLI.password_prompt "#{data}"
channel.send_data "#{response}\n"
end
else
logger.info data, channel[:host]
end
end
end
的代码都不是我的。格拉西亚斯奈斯克纳。