【问题标题】:Linux screen input automatic responseLinux屏幕输入自动响应
【发布时间】:2014-06-17 05:08:48
【问题描述】:

我有一个提示用户键盘输入的 python 程序。根据输入完成某段代码。

List of items in this dfsu file:

1.  Significant Wave Height
2.  Peak Wave Height
3.  Wave Direction

Chose item from the list above

我想总是选择 1,由于这个问题重复了 5000 次,我不想手动输入 1。我无权访问源代码来硬编码,但我想知道是否有每次问这个问题时强制用户输入为 1 的方法?

谢谢, 金佰利

【问题讨论】:

    标签: linux input prompt


    【解决方案1】:

    有没有办法在每次问这个问题时强制用户输入为 1?

    yes,有。

    运行 yes 并将其输出通过管道传递给您运行的命令:

    yes 1 | the_command_you_originally_ran
    

    默认情况下,yes 重复输出y,假设您想自动确认类似“are-you-sure”的提示,但您可以运行yes 1 使其无限输出1循环。

    【讨论】:

    • 谢谢!完美运行。
    猜你喜欢
    • 2014-11-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-12-11
    • 1970-01-01
    • 1970-01-01
    • 2019-06-27
    • 2011-04-19
    相关资源
    最近更新 更多