问题描述
我有一个采用了读
命令来读取参数交互命令,例如选择Yes / No bash脚本。有没有一种方法来调用这个脚本在非交互式脚本传递默认选项值作为参数?
I have a bash script that employs the read
command to read arguments to commands interactively, for example yes/no options. Is there a way to call this script in a non-interactive script passing default option values as arguments?
这不只是一个选项,我要传递给交互脚本。
It's not just one option that I have to pass to the interactive script.
推荐答案
有关更复杂的任务有期望
()。
它基本上模拟了一个用户,您可以code脚本如何具体计划产出和相关的东西做出反应。
For more complex tasks there is expect
( http://en.wikipedia.org/wiki/Expect ).It basically simulates a user, you can code a script how to react to specific program outputs and related stuff.
这也适用于情况下,像 SSH
禁止管道密码吧。
This also works in cases like ssh
that prohibits piping passwords to it.
这篇关于传递参数给交互式程序交互的非的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!