#服务器IP地址数组
ips=(
ip1...
ip2...
ip3...
...
)
#遍历数组
for ip in ${ips[*]}
do
/usr/bin/expect<<-EOF #shell中使用expect
set timeout 90
spawn ssh user@$ip
expect "passphrase"
send "password\r"
expect "user"
send "cd /dir\r"
expect "dir"
send "cat file.properties\r"
expect "propertiy"
exit
interact
expect eof
EOF
done
#遍历请求ip服务器
ips=(
ip1
ip2
...
)
for ip in ${ips[*]}
do
url="http://"${ip}"/..."
echo $ip
resp="$(curl -s "$url")" #-s 去掉一些请求头信息
echo "$resp"
result=`echo "$resp" | grep "<message>ok</message>"` #resp变量必须加引号,否则遇到xml格式文字显示会乱序
#echo $result
if [ "$result" != "" ]
then
echo "测试通过"
else
echo "测试失败"
fi
done