linux except命令使用 自用记录
set timeout 30
set host "172.111.110.112"
set username "root"
set password "******"
spawn scp -P 12345 ./test.exp $username@$host:/opt/test/test
expect {
"*yes/no" {send "yes\r"; exp_continue}
"*Password:*" {send "$password\r"}
}
interact
set timeout 30
set host "172.111.110.112"
set username "root"
set password "******"
spawn ssh -p 12345 $username@$host
expect {
"*yes/no" {send "yes\r"; exp_continue}
"*Password:*" {send "$password\r"}
}
interact
#!/bin/bash
/usr/bin/expect <<-EOF
spawn mysql -u root -p123456
expect "*>*"
send "show databases;\r"
expect "*>*"
send "quit;\r"