#!/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\n"; expect "*assword:" { send "$UFEPwd\n" } } "*assword:" { send "$UFEPwd\n"; } } expect "]#" send "mysql -uroot -p$UFEDBPwd -e ‘delete from cc.search_records; delete from cc.tasks;delete from tt.fileinfo; delete from tt.taskinfo;‘\r" expect "]#" send \003 spawn ssh $User@$SMNIpAddr expect { "yes/no" { send "yes\n"; expect "*assword:" { send "$SMNPwd\n" } } "*assword:" { send "$SMNPwd\n"; } } expect "]#" send "mysql -uroot -p$SMNDBPwd -e ‘delete from scc.taskrecord; delete from scc.localvideorecord; delete from scc.videorecord;‘\r echo ‘DELED‘\r" expect "]#" send \003
原文:http://www.cnblogs.com/dorothychai/p/4381773.html