======expect.exp=====
#!/usr/bin/expect
set timeout -1
set ip [lrange $argv 0 0]
set user [lrange $argv 1 1]
set pw [lrange $argv 2 2]
spawn ssh $user@$ip
expect {
"(yes/no)" { send "yes\r" }
"password:" { send "$pw\r" }
}
interact
=====================
#!/bin/bash
user=root
pw=xxxxxx
for i in {141..143}
do
ip=10.20.142.$i
/home/test/expect.exp $ip $user $pw
done
阅读(2718) | 评论(0) | 转发(0) |