sh脚本和bash脚本
I work on a project that requires I frequently build and destroy a virtual machine. I don't enjoy having to do so but virtual machines can be notoriously difficult to prop up, especially when you have a complex app living within it.
我从事的项目需要经常构建和销毁虚拟机。 我不喜欢这样做,但是众所周知,虚拟机很难支撑,尤其是当其中包含复杂的应用程序时。
Manually typing the same commands over and over can be mind-numbing so I've create a bash script to handle all of the work for me. One hiccup to the process is needing to confirm removal of an existing virtual machine; using a pipe and echo
allows me to answer the prompt:
一遍又一遍地手动键入相同的命令可能会让人麻木,因此我创建了一个bash脚本来为我处理所有工作。 困扰该过程的一个问题是需要确认已删除现有虚拟机。 使用管道和echo
可以回答提示:
# ... some directives here# Remove the machine, confirming "y" when asked by docker-machineecho 'y' | docker-machine rm default# ... more directives here
Using echo
I pipe a y
response to docker-machine
's confirmation prompt, thus allowing the script to move forward with other tasks without the need for manual intervention.
使用echo
我将对docker-machine
的确认提示的响应发送给y
,从而使脚本可以继续执行其他任务,而无需手动干预。
I don't, however, know how to handle multiple prompts -- can you tell me and everyone else?
但是,我不知道如何处理多个提示-您能告诉我和其他所有人吗?
翻译自:
sh脚本和bash脚本