在模拟bash脚本ENTER键preSS [英] Simulating ENTER keypress in bash script

查看:190
本文介绍了在模拟bash脚本ENTER键preSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建运行一些命令一个非常简单的bash脚本。
这些命令的人需要在运行时用户输入。即它要求用户你想等等等等等等?,我想简单地发送一个回车键preSS这使该脚本就会被完全自动化。

我将不必等待运行时输入或任何东西,它足以只发送键preSS和输入缓冲区将处理剩下的。


解决方案

 回声-ne的'\\ n'| < yourfinecommandhere>

或采取呼应隐含换行的优势产生(感谢马辛)

 回声| < yourfinecommandhere>

I've created a really simple bash script that runs a few commands. one of these commands needs user input during runtime. i.e it asks the user "do you want to blah blah blah?", I want to simply send an enter keypress to this so that the script will be completely automated.

I won't have to wait for the input or anything during runtime, its enough to just send the keypress and the input buffer will handle the rest.

解决方案

echo -ne '\n' | <yourfinecommandhere>

or taking advantage of the implicit newline that echo generates (thanks Marcin)

echo | <yourfinecommandhere>

这篇关于在模拟bash脚本ENTER键preSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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