让 bash 脚本回答交互式提示 [英] Have bash script answer interactive prompts

查看:31
本文介绍了让 bash 脚本回答交互式提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以让 bash 脚本自动处理通常会以默认操作呈现给用户的提示?目前我正在使用 bash 脚本调用一个内部工具,该工具将向用户显示提示(提示 Y/N)以完成操作,但是我正在编写的脚本需要完全不干涉",所以我需要一种方法将 Y|N 发送到提示以允许程序继续执行.这可能吗?

Is it possible to have a bash script automatically handle prompts that would normally be presented to the user with default actions? Currently I am using a bash script to call an in-house tool that will display prompts to the user (prompting for Y/N) to complete actions, however the script I'm writing needs to be completely "hands-off", so I need a way to send Y|N to the prompt to allow the program to continue execution. Is this possible?

推荐答案

这不是自动完成",这是自动化.用于这些事情的一种常用工具称为 Expect.

This is not "auto-completion", this is automation. One common tool for these things is called Expect.

您也可以通过管道输入来自 yes.

You might also get away with just piping input from yes.

这篇关于让 bash 脚本回答交互式提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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