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,716
  • 9
  • 32
  • 47

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
  • 38,065
  • 11
  • 68
  • 78
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
  • 5,040
  • 13
  • 41
  • 61