dsfh40613182 2015-03-03 22:09
浏览 159
已采纳

Linux bash脚本模拟输入

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 . But with my bash script it is not working as it should. Also the echo -ne | 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. 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. 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.

thanks

  • 写回答

1条回答 默认 最新

  • doucan9079 2015-03-29 15:24
    关注

    If command is a command that asks for an input (for example a confirmation where you have to enter 'Y' or 'N'), this will do the trick:

    echo "N" | command
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 vb6.0截取当前窗体保存为jpg文件
  • ¥20 苹果手机不使用大疆sdk怎么获取遥控器控制信息或如何接入大疆sdk并且成功上架sdk
  • ¥15 改动头文件造成的编译错误如何解决
  • ¥20 woocommerce 注册按键重定向
  • ¥100 求书法图像文字切割代码
  • ¥15 同一个波形探测距离不同的目标,为什么fft之后得到的频谱图会发生移动,不应该时移不改变幅度谱吗(标签-matlab)(相关搜索:matlab仿真)
  • ¥15 Proteus仿真程序只能执行一次
  • ¥15 语音识别websocket报错
  • ¥15 激光器,引脚问题,无法处理
  • ¥20 求写一份!只提交Mapper映射文件 如:UsersMapper.xml