0

I am using CentOS 6.3.

How can I ignore or write 'y' when the terminal prompts a question?

For example, when I run 'yum install java-1.7.0-openjdk', it prompts me with this statement

Is this ok [y/N]:

Is there anyway I could ignore or always say yes to the question?

Jee Seok Yoon
  • 4,549
  • 9
  • 30
  • 46

2 Answers2

2

In the case of yum it takes an option -y that answers yes to all questions asked.

yum -y install java-1.7.0-openjdk

For other installations you can try to pipe the command yes to the process but I'm not sure it would work with every program. Try it first.

yes | yum install java-1.7.0-openjdk
Andreas Wederbrand
  • 35,944
  • 10
  • 64
  • 76
1

Yes, you can use Spawn.

#!/usr/bin/expect -f
spawn yum install java-1.7.0-openjdk
expect "[y/N]:" 
send "y\r"
interact

I'm not tested but I found "auto-terminal" here

Community
  • 1
  • 1
Davuz
  • 4,684
  • 13
  • 39
  • 58