Is there a way I can IF CONDITION an expect command. For example in the below code, I am trying to ssh into a specific IP address and sometimes it asks me "Are you sure you want to continue connecting (yes/no)?" and sometimes it doesn't. How do I make it so that IF it shows up I send "yes/r" and IF it doesn't, I continue on with my code?
set name="123.456.78.910"
expect "$ " ; send -- "ssh root@$name\r"
expect {
"Password:" { send "password" }
timeout { sleep 1 }
}
expect "Are you sure you want to continue connecting (yes/no)?" ; send -- "yes\r”