Automate with expect

  Snippets, bash snippets

#!/usr/bin/expect -f
# catch the date passed on the command line and assign it to a variable
set thedate [lindex $argv 0]
# connect to remote server
spawn scp "user@server:/backups/*$thedate*" /backups_archives
#######################
expect {
-re ".*es.*o.*" {
exp_send "yesr"
exp_continue
}
-re ".*sword.*" {
exp_send "your_passwordrr"
}
}
interact

Read more about expect here: http://linux.die.net/man/1/expect