本文介绍了无业游民条款:从键盘/stdin读取行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以,我有一个带有代码的Vagrantfile:
And so, I have a Vagrantfile with code:
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
...
config.vm.provision "shell", inline: 'echo "Read line:" && read t && echo "$t"'
...
end
当我执行vagrant provision
时,我得到的输出是:
and when I execute vagrant provision
i have that output:
$ vagrant provision
...
==> default: Running provisioner: shell...
default: Running: inline script
==> default: Read line:
==> default: exit
这不建议在键盘/标准输入框中输入一行!
that is no suggest enter a line from keyboard/stdin!
在配置外壳脚本执行过程中,如何从键盘/stdin读取行?
What I should do for reading line from keyboard/stdin during provision shell script execution?
推荐答案
我这样做是在我的Vagrantfile中
I do it this way, in my Vagrantfile
puts "Input text: "
input = STDIN.gets.chomp
config.vm.provision :shell, inline: "echo #{input}"
这篇关于无业游民条款:从键盘/stdin读取行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!