ssh的例子:
user01=admin
IP01=192.168.44.113
expect -c "
set timeout 60
spawn ssh $user01@$IP01
expect {
\"yes/no\" {
sleep 1
send \"yes\\n\"
exp_continue
}
\"ssword:\" {
sleep 1
send \"admin123\\n\"
}
timeout { exit 1}
}
interact
"
telnet的例子:
user01=admin
IP01=10.200.200.1
expect -c "
set timeout 60
spawn telnet $IP01
expect {
\"Username\" {
sleep 1
send \"admin\n\"
exp_continue
}
\"ssword:\" {
sleep 1
send \"wp1@gw.com\\n\"
}
timeout { exit 1}
}
interact
"