创建bash脚本应答文件 [英] Create answer file for bash script

查看:111
本文介绍了创建bash脚本应答文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创造偷别人的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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆