标签:dmi expect spawn code lis ssh ash password shel
Expect脚本批量执行命令
#!/bin/bash
cat /root/iplist|while read line
do
a=($line)
expect <<EOF
set timeout 3
spawn ssh root@${a[0]}
expect {
"*yes/no" { send "yes\r" }
"*password:" { send "${a[1]}\r" }
}
expect -re ".*\[\$#\]"
send "df -h\r"
expect -re ".*\[\$#\]"
send "exit\r"
expect eof
EOF
done
ps:iplist
192.168.1.11 admin@123
192.168.1.12 admin@223
标签:dmi expect spawn code lis ssh ash password shel
原文地址:https://www.cnblogs.com/kolord/p/13399220.html