#!/bin/bash


server=$1

ssh -o ConnectTimeout=5 root@$server "exit"
conn_check=$(echo $?)

echo "$conn_check"

if [ $conn_check = 0 ]

  then

   echo "--Log: I can see the ESXI is up and I will poweroff the server"
   echo "--Log: executing poweroff cmd"
   sleep 3s

fi

if [ $conn_check -eq 255 ]

  then

  echo " -- Log: I was no table to connect to the server"
  echo " -- Log: not trying to shutdown the server"

fi

echo " -- Log: Endo of the Script"