我有一个java cli,要求用户传递y或n。我必须执行大约一千次,并且CLI中的所有支持都没有。如何自动将y传递给此cli?
示例:
$ ./command-to-run
do you want to delete x? (y/N) y
do you want to delete x1? (y/N) y
do you want to delete x2? (y/N) y
.
.
do you want to delete x1000? (y/N) y
我试过
seq 1000 | xargs -Is echo 'y' | ./command-to-run
它没有工作
答案 0 :(得分:5)
一种方法是使用yes
command line application:
yes | ./command-to-run
对于更复杂的互动,有expect
application in multiple languages。