#!/bin/bash
n=0
while :
do
n=$((n+1))
echo "test count=" $n
expect << __EOF
set timeout 30
spawn ssh root@192.168.2.195
expect {
"(yes/no)?" { send "yes\r" ; exp_continue }
"password:" { send "123456\r" }
}
expect "iBMC:/->"
send "ipmcset -d powerstate -v 2\r"
expect "Do you want to continue\?\[Y\N\]:"
send "Y\r"
sleep 5
expect "iBMC:/->"
send "ipmcset -d powerstate -v 1\r"
expect "Do you want to continue\?\[Y\N\]:"
send "Y\r"
expect "iBMC:/->"
send "exit\r"
interact
__EOF
sleep 5m
done
在shell中插入expect命令。
最新推荐文章于 2024-05-01 02:33:18 发布