#!/bin/bash
PASS='password'
for ip in $(cat ip.txt); do
expect -c "
set timeout 5;
spawn scp -rp ip.txt root@$ip:/tmp
expect {
\"(yes/no)\" {send \"yes\r\"; exp_continue}
\"password:\" {send \"$PASS\r\"; exp_continue}
}
"
echo ""
done
标签:示例,ip,send,expect,使用,yes,txt
From: https://www.cnblogs.com/xwjh/p/17141671.html