#!/usr/bin/expect -f
#set timeout 20
set sp YourSudoPassword
set passwd UserPassword
# sudo is not always necessary
spawn sudo ssh user@ip
expect "Password:"
send "$sp\r"
expect "some stuff"
send "$passwd\r"
interact
- spawn: run commands
- expect: wait for specify pattern
- send: to send the strings to the process