以非交互方式将参数传递给交互式程序 [英] Passing arguments to an interactive program non-interactively

查看:28
本文介绍了以非交互方式将参数传递给交互式程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 bash 脚本,它使用 read 命令以交互方式读取命令的参数,例如是/否选项.有没有办法在传递默认选项值作为参数的非交互式脚本中调用此脚本?

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.

推荐答案

对于更复杂的任务,有 expect ( http://en.wikipedia.org/wiki/Expect).它基本上是模拟用户,您可以编写脚本如何对特定程序输出和相关内容做出反应.

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屋!

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