Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The following code isn't working, but what I want to do is answer "n" whenever YUM asks whether I want to install the software or not. Thanks

#!/usr/bin/expect -f

spawn yum install emacs
expect "Is this ok \[y\/N\]:"
send "n\r"
share|improve this question
    
add exp_internal 1 at the top of the script and re-run. That will give you lots of debugging info – glenn jackman Mar 29 '12 at 23:50

Starting with your code snippet this is what I got to work

#!/usr/bin/expect -f

expect -c  "
    set timeout 15
    spawn yum install emacs

    expect {
        "]:"        { send n\r ; sleep 1 ; exp_continue  } 
    }
"

it also works with #!/bin/bash at the top

share|improve this answer

From the yum manpage:

-y, --assumeyes
    Assume yes; assume that the answer to any question which would be asked is yes.
    Configuration Option: assumeyes

So just use yum -y instead of messing around with expect.

share|improve this answer

change the expect "Is this ok \[y\/N\]:"

to

expect "]:"

are you geting the same error? if not its a typo in your expect.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .