Automatically “Press Enter to Exit” in bash?

末鹿安然 提交于 2019-12-11 08:54:20

问题


In a bash script, I'm using wine to call a DOS program that requires me to "Press Enter to exit". How do I do that automatically and continue with the rest of the script?


回答1:


echo | wine dosprogram.exe




回答2:


You might be able to use the expect program.

Here is an example script:

spawn /path/to/program/Dynamips
expect -- "->"
send "start R1\r"
expect -- "->" {
  sleep 5
  send "start R2\r"
}
expect eof

You can invoke this with:

expect scriptname



回答3:


Send it the input 0x0D



来源:https://stackoverflow.com/questions/1349771/automatically-press-enter-to-exit-in-bash

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!