Automate with expect

#!/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

 

Tags

Related Posts

Share This

Rename a schema (sort of)

To rename a schema (emulating the now-dropped RENAME DATABASE functionality):

 SELECT concat('RENAME TABLE oldSchema.',table_name, ' TO newSchema.',table_name, ';')
 FROM information_schema.TABLES
 WHERE table_schema='oldSchema';

Execute the resultant sql, then drop the now-empty old schema.

 

Tags

Related Posts

Share This