We have quite a lot of servers but they all are like bellow format
(3 server in a pair)
So basically the different is : k,h,v
Now Problme is :
I need to run a script from one of the server and it will connect to
rest 2 by ssh and will run a command, which i know how to do
but i dont know ,how will i know from which server i am running and how
to get hostname of the rest 2 servers.
#I Assuming I am running the script from DK-vk-2.domain.lan, So
i need to connect to rest 2 server
@hostname1 = " DK-vm-2.domain.lan "
@hostname2 = " DK-vh-2.domain.lan "
problem is : i need set the hostname1 and hostname2 Automatically
depends on the server i am running the script.
i can get the hostname of the server by using
so it might be
So if its vk , then rest 2 server will be vm,vh
so the rest of 2 server would be , DK-vm-2.domain.lan ,
only differerence is “m” and “h”
other way round
if i run the script from
DK-vh-2.domain.lan , the other 2 server will be
CAn any one help me …
i am quite stuck now …I would be really grateful if any one can help me