Jasmine Lognnes
Jasmine Lognnes

Reputation: 7107

Possible for "expect" to only answer some questions?

The problem with this script is that if there are any yum updates, then it still exits.

#!/usr/bin/expect

spawn su -c "yum update"
expect "Password: "
send "secret\n"
expect eof
exit

I would like to be able to answer yes or no in that situation.

Question

Is it possible to just have except to answer the password question, and then let the rest be interactive?

Upvotes: 2

Views: 98

Answers (1)

pynexj
pynexj

Reputation: 20798

For example:

#!/usr/bin/expect

spawn su -c "yum update"
expect "Password: "
send "secret\n"
interact
exit

Upvotes: 1

Related Questions