Sorry about that, my english isn't very good at the best of times.
To try and make it easier I will include my current script. At the minute this scipt runs on my primary server. I want to modify it so that it will connect to my secondary server via ssh and execute the bash commands. I realise the port probing will not be a problem I can just change the IP address.
EDIT:: removed attachment