如何在脚本 ksh 中自动提示输入键,然后输入 yes no

如何在脚本 ksh 中自动提示输入键,然后输入 yes no

我在脚本中有一个命令,提示用户首先按回车键,然后按“是”或“否”。创建一个基本脚本来自动回答是或否问题不是问题。我发现很难找到使用 Enter 提示键自动执行脚本的命令。

提示如下:

Please mount tape 1 on /ddomain/data/centdctst1/centdctst1/data and press Return to continue ...
Continue restore? (y/n)
Do you want to back up the logs? (y/n)
Restore a level 1 archive (y/n)

为了使该过程自动化,我可以使用以下命令:

ontape -p <<!
<enter key command>
y
n
n
!

在脚本中使用上述内容不起作用。我正在寻找一种按 Enter 键然后输入是或否问题的方法。

相关内容