远程清除数据库的脚本

#!/usr/local/bin/expect -f

set timeout -1

set UFEIpAddr “”
set User “”
set UFEPwd ""
set UFEDBPwd ""

set SMNIpAddr ""
set SMNPwd ""
set SMNDBPwd ""

spawn ssh $User@$UFEIpAddr
expect  {
        "yes/no" { send "yes
"; expect "*assword:" { send "$UFEPwd
" } }
        "*assword:" { send "$UFEPwd
"; }
}
expect "]#"
send "mysql -uroot -p$UFEDBPwd -e 'delete from cc.search_records; delete from cc.tasks;delete from tt.fileinfo; delete from tt.taskinfo;'
"
expect "]#"
send 003

spawn ssh $User@$SMNIpAddr
expect  {
        "yes/no" { send "yes
"; expect "*assword:" { send "$SMNPwd
" } }
        "*assword:" { send "$SMNPwd
"; }
}
expect "]#"
send "mysql -uroot -p$SMNDBPwd -e 'delete from scc.taskrecord; delete from scc.localvideorecord; delete from scc.videorecord;'
 echo 'DELED'
"
expect "]#"
send 003
原文地址:https://www.cnblogs.com/dorothychai/p/4381773.html