非交互地将参数传递给交互式程序 [英] Passing arguments to an interactive program non-interactively
本文介绍了非交互地将参数传递给交互式程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个bash脚本,该脚本使用read
命令以交互方式读取命令的参数,例如yes/no选项.有没有办法在将默认选项值作为参数传递的非交互式脚本中调用此脚本?
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.
推荐答案
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.
这篇关于非交互地将参数传递给交互式程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文