创建bash脚本应答文件 [英] Create answer file for bash script
问题描述
我想创造偷别人的bash脚本应答文件。当您运行bash脚本,你问5个问题你安装软件的第一次。
I would like to create an answer file for somebody elses bash script. When you run the bash script, you are asked 5 questions the first time you install the software.
我用是| ./script
命令和它的作品,它会自动接听是
来的所有问题。不过,我想回答没有
的最后一个问题。有没有办法回答是
来的第4个问题,而没有
第五?
I used the yes | ./script
command and it works, it automatically answers yes
to all of the questions. However, I would like to answer no
for the last question. Is there a way to answer yes
to the first 4 questions, and no
to the fifth?
推荐答案
提供这种方式,或直接从一个文件你的答案标准输入
provide your answers in this way or from a file directly to stdin
./script << EOF
yes
yes
yes
yes
no
EOF
(使用是
或是
取决于你的脚本将期望 - 可能只是是
和 N
就足够了,因为是
程序工作)。
(use y
or yes
depending on what your script will expect - probably just "y
" and "n
" will be enough since yes
program works).
有关更复杂的任务,你最终可能会考虑使用像期待(的维基百科页面)
For more complex tasks you may eventually consider using something like Expect (wikipedia page)
这篇关于创建bash脚本应答文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!