vim scp.sh
#!/bin/bash
yum -y install expect
/usr/bin/expect<<EOF
spawn scp 11.text $1:/root #首先执行spawn命令开始
expect “yes/no” {send “yes\n;exp_continue”} #当遇到"yes/no"执行yes,当没出现"yes/no"则跳过
expect “password” {send “123456\n”} #当遇到"password"执行yes
expect eof #结尾
EOF
运行:
sh scp.sh IP地址
expect脚本scp远程拷贝
最新推荐文章于 2023-11-28 23:02:40 发布