Executing commands in different server

Hi Friends,

I have a situation here, where I have a script running in one server, namely "SERVER1". Within this script which runs in SERVER1, I have a set of commands which has to connect to a different server (namely "SERVER2") and execute the commands accordingly. I have no experience at all in scripting and will be grateful if somebody could help me sort this out.

Please find below the script which I have developed so far.
The problem is, once the script reaches "ssh SERVER2", it connect to the server and the prompt appears (server2 prompt).
What I need is, the script has to connect to SERVER2 and execute the commands in that server and complete the rest of the commands in the script.

#! /usr/bin/ksh
echo "Please choose any one of the below options:" 
echo "1)apple" 
echo "2)mango" 
echo "3)grapes" 
echo "4)banana\n" 
read i;
case i in
1)  ssh SERVER2
 cd /home/apple
 FAILED_FILE=`ls apple*`
 if [ -f  ${FAILED_FILE} ]; then
  cp -p ${FAILED_FILE} /home/apple/delivered/
 fi
exit
echo "Copy success"
 ;;
*) echo "Invalid option selected"
esac

Here is the ssh part try.

(
 echo "cd /home/apple"
 another command..
 .......
 
 echo "~."
) ssh -T SERVER2