shell腳本使用expect交互

linux安裝expectlinux

yum install tcl-devel
yum install expectbash

#!/bin/bash
/usr/bin/expect <<EOF
set timeout 30
spawn ssh root@baba.fc417.top
expect {
"*yes/no*" {send "yes\r"}
"*password*" {send "密碼\r"}
}
expect "root@*"
send "mkdir /root/fc/1231\r"
expect "root@*"
send "exit\r"
expect eof
spawn scp -r /root/fc/1231 root@baba.fc417.top:/root/lx
expect {
"*yes/no*" {send "yes\r"}
"*password*" {send "密碼\r"}
}
expect eof
EOF服務器

http://www.fc417.topssh

相關文章
相關標籤/搜索