Executing scipts after logging into a remote host using shell script

Hi All,

Sorry if it is a duplicate post. I have not got any reference about this anywhere.

I looked at the posts described in SSH - Passing Unix login passwords through shell scripts - Linux / UNIX Forum and it helped me till the point to connect to the host and executing the basic commands.

But my questions is here- Can i connect to a Database after logging into the host. Could you throw some pointers in this regard.

Note: I have a script called DBConnect.sh which needs to be executed on the remote host.

---------- Post updated at 10:55 PM ---------- Previous update was at 10:53 PM ----------

I'm trying to do all this through a shell script (even after logging into the remote host also)

ssh username@servername "/path/of/your/remote/script" > log.txt

if you are having DBConnect.sh at your remote machine, then you can execute it like any other command in the remote machine.

This is quite confusing. what are looking for exactly.

This is how you can scripts through ssh.

ssh user@host "/home/user/DBConnect.sh option1 otpion2" 

if i use the below it will prompt me for password.

ssh user@host "/home/user/DBConnect.sh option1 otpion2"

I'm trying to do it through a shell script. So i dont want it to be in interactive mode.

My script requirements are as follows:

1) i have a script1.sh running on machine1
2) So script1.sh should be able to connect to machine2 and execute the scripts inside the machine2.

This is how my requirements are. Please help me if you have some idea.