#!/bin/bash
function ssh_oprate
{
local ip=$1
local username=$2
local password=$3
expect -c"
set timeout -1
spawn ssh $username@$ip
expect -re \".*\[>|#].*\"
send \"sh /opt/oss/get_services_version/get_service_version.sh \r\"
expect -re \".*\[>|#].*\"
send \"exit\r\"
"
}
function get_properties
{
local remoteip=$1
local username=$2
local password=$3
scp -r $username@$remoteip:/opt/oss/get_services_version/service_version.properties ./
}
ssh_oprate 10.47.55.42 root Huawei@123 >/dev/null 2>&1
if [ $? -ne 0 ];then
echo "Failed to execute Shell!"
exit 1
fi
get_properties 10.47.55.42 root Huawei@123 >/dev/null 2>&1
if [ -f service_version.properties ];then
echo "=======================当前所有已部署服务的版本号============================"
cat service_version.properties
else
echo "Failed to get service_version.properties"
exit 1
fi