how to pass keyboard input along to linux command?

后端 未结 3 1339
一个人的身影
一个人的身影 2020-12-16 20:55

I run a linux command that sometimes asks for user input (press 1 or 2).

I always want to answer 1, how can I pass this value automatically ?

3条回答
  •  长情又很酷
    2020-12-16 21:18

    Just a thought:

    echo "1" | linux_command --with-arguments <&0
    

    This works for commands which want input from stdin, because 0 is the descriptor for standard input. This question might better belong on Server Fault however...

提交回复
热议问题