在bash脚本提示后如何编程输入? [英] How do I programmatically input after a prompt with bash script?

查看:101
本文介绍了在bash脚本提示后如何编程输入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须运行bash脚本bash.sh,该脚本启动命令行工具.

I have to run a bash script bash.sh that starts up a command line tool.

该命令行工具提示输入Please enter your email:

That command line tool has a prompt that says Please enter your email:

然后,我需要一种在提示后以编程方式输入我的电子邮件的方法.

I then need a way to programmatically enter my email after the prompt.

我只是尝试了myemail@email.com而我已经尝试了echo myemail@email.com.似乎都不起作用,因为提示不允许我再运行任何命令.

I have tried simply myemail@email.com and I have tried echo myemail@email.com. Neither seem to work because the prompt does not allow me to run any more commands.

这可行吗?

推荐答案

将其传递给stdin:

Pass it to stdin:

command_line_tool <<< "my@email.com"

进一步阅读:

  • http://www.tldp.org/LDP/abs/html/io-redirection.html
  • http://tldp.org/LDP/abs/html/x17837.html

这篇关于在bash脚本提示后如何编程输入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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