I have to write a shell script in my current linux server and I have to connect to a different server then do sudo login and finally run some scripts residing in a particular directory and get results back. I am starting to write my shell script as below but after I do ssh login it prompts for password and shows command prompt and script halt there and script does not proceed further.
SERVER_IP=10.00.000.00
SV_INSTANCE_NAME=abcxyz1b
...
..
# ssh to SV server_ip
ssh xusername@$SERVER_IP
# sudo login to instance
sudo su - $SV_INSTANCE_NAME
...
..
I wish to know is this the right way to connect and run script residing in a different server or there can be some better to do what I wish to achieve.