分类: 系统运维
2016-12-26 17:05:03
#!/usr/bin/expect
set timeout 1
eval spawn [lrange $argv 0 end]
expect "password:"
send "changeme\r"
interact
#!/usr/bin/expect
set timeout 1
set username [lindex $argv 0]
set password [lindex $argv 1]
eval spawn [lrange $argv 2 end]
expect {
"Password:"{
send "$password\n"
}
timeout {
exit
}
# for i in `cat ip` ; do ./expect.sh ssh 'ifconfig eth0 |grep HWaddr; exit' ; done >output