Executing scipts after logging into a remote host using shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Executing scipts after logging into a remote host using shell script
# 1  
Old 06-16-2011
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)
# 2  
Old 06-16-2011
Code:
ssh username@servername "/path/of/your/remote/script" > log.txt

# 3  
Old 06-16-2011
if you are having DBConnect.sh at your remote machine, then you can execute it like any other command in the remote machine.

Quote:
I'm trying to do all this through a shell script (even after logging into the remote host also)
Reply With Quote
This is quite confusing. what are looking for exactly.

This is how you can scripts through ssh.
Code:
ssh user@host "/home/user/DBConnect.sh option1 otpion2"

# 4  
Old 06-16-2011
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to keep staying on remote server after executing a shell script with if then exit end statement?

i have a "if .. then exit end " in s shell script on remote servers. now the connection to the remote server got killed after i run this script on the remote servers. How do i run this script on remote hosts and still keep remote connections alive after executing the script. Thank you. (10 Replies)
Discussion started by: moonmonk
10 Replies

2. Shell Programming and Scripting

Check/get the exit status of a remote command executed on remote host through script

Geeks, Could you please help me out in my script and identify the missing piece. I need to check/get the exit status of a remote command executed on remote host through script and send out an email when process/processes is/are not running on any/all server(s). Here's the complete... (5 Replies)
Discussion started by: lovesaikrishna
5 Replies

3. Shell Programming and Scripting

Pause processes in remote host and resume execution in another remote host

Hi, Given addresses of 2 remote machines, using a shell script is it possible to get the state of running processes in "src" stop all the processes in "src" exit out of "src" ssh into "dest" resume the state of executing processes captured in step 1 in "dest" Assumption: "src" is... (3 Replies)
Discussion started by: Saeya Darsan
3 Replies

4. Shell Programming and Scripting

How to run a shell script on a remote host using ftp

Hi, is there a way I can run a shell script through ftp on a remote host? The remote host doesn't have ssh running so I can't use ssh. (7 Replies)
Discussion started by: mrskittles99
7 Replies

5. Shell Programming and Scripting

executing command in a remote machine through ssh - shell script

Hi All, i have two machines like x and y . my requirement is i should connect to machine Y from x through ssh connection . and do some operation such as copy and move and delete files in Y machine . i tried with this code but it is doing in machine x only . and i need to exit from Y when... (1 Reply)
Discussion started by: rateeshkumar
1 Replies

6. Shell Programming and Scripting

Run a shell script from one host which connext to remote host and run the commands

I want to write a script which would run from one host say A and connect to other remote host B and then run rest of commands in that host. I tried connecting from A host to B with SSH but after connecting to host B it just getting me inside Host B command prompt. Rest of the script is not running... (6 Replies)
Discussion started by: SN2009
6 Replies

7. Shell Programming and Scripting

stop logging when executing a script

Hi guys if for every command you issued successfully where to be logged from a script and them sent an email to the admistrator how could i stop that so that i wouldnt have to delete admin mail all the time. I would only want to produce output if there was an error. (5 Replies)
Discussion started by: musicmancanora
5 Replies

8. Shell Programming and Scripting

How can my unix shell script automatically connect to remote host?

How can my unix shell script automatically connect to remote host? Assume that there is a remote host called "rhost". When I connect to that host i give the command "telnet rhost". It then asks me for my id and password. Once i give it connects there. I want to automate these steps. I want... (8 Replies)
Discussion started by: digdarshan
8 Replies

9. UNIX for Dummies Questions & Answers

Sh Shell Script executing remote SQL queries

Hi there folks, I am trying to execute remote sql queries on an Oracle server. I would like to save the result of the executed sql queries on a text file, and send that text file as an attachment to an email address. Could anyone give me an idea on how the above could be achieved? Any help... (2 Replies)
Discussion started by: Javed
2 Replies

10. Shell Programming and Scripting

Problem with logging into remote host

Hi All, I am using a script for remotely logging into a rhost using telnet and shutdown a server. The script is as follows. IP = 10.24.12.23; export IP UNAME = username ; export UNAME PWD = password; export PWD CRDIR = /etc/rc.d/init.d ; export CRDIR echo "logging into remote... (4 Replies)
Discussion started by: patil_reddy
4 Replies
Login or Register to Ask a Question