简体   繁体   English

Linux bash脚本模拟输入

[英]Linux bash script simulate enter

I am pretty new to bash scripting and i have looked every where over the web and i have find several ways to simulate an enter push like you would normally do with php cli \\n. 我是bash脚本的新手,我已经看过网络上的每一个地方,我已经找到了几种模拟输入推送的方法,就像你通常用php cli \\ n做的那样。 But with my bash script it is not working as it should. 但是使用我的bash脚本它不能正常工作。 Also the echo -ne \\n | 回声-ne \\ n | y stuff like that. 这样的东西。

The problem is that i am trying to install a control panel (zpanel) ad have every question auto answered by bash. 问题是,我正在尝试安装一个控制面板(zpanel)广告,每个问题都由bash自动回答。 But how do i do this when the install script asks me if i want to continue. 但是,当安装脚本询问我是否要继续时,我该怎么做呢? In this case i need to put in y and then press enter. 在这种情况下,我需要输入y然后按回车键。 Another question i just need to push enter and so on. 另一个问题我只需要输入等等。

I hope some one can help me with this and how that is being handled in bash scripts. 我希望有人可以帮助我解决这个问题,以及如何在bash脚本中处理这个问题。

thanks 谢谢

如果command是一个要求输入的命令(例如,你必须输入'Y'或'N'的确认),这将解决问题:

echo "N" | command

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM