詳情:shell & expect 實(shí)現(xiàn) MySQL 命令行自動(dòng)登錄
重點(diǎn)
#!/usr//bin/expect -f
set ip [lindex $argv 0]
set port [lindex $argv 1]
set user [lindex $argv 2]
set password [lindex $argv 3]
spawn mysql -h$ip -u$user -P$port -p
set timeout 1000
expect "Enter password:"
send "$password\r"
expect ">"
send "use xxx_database\r"
interact