Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

3 Answers 3

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

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

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.