shell脚本使用expect交互


linux安装expect

yum install tcl-devel
yum install expect

#!/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.top


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM