Exiting the Remote server after script execution


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Exiting the Remote server after script execution
# 1  
Old 11-04-2014
Exiting the Remote server after script execution

Hi All ,

I'm running a script abc.sh in server "host1" shown as below :

Code:
#! /bin/bash

sh stop.sh

ssh user@$host2 "/home/user/prod_work/xyz.sh; 

sh start.sh


The problem I am facing is , the control is not passed to host1 after executing the script "xyz.sh" in host2 .

How to exit the session in host2 after executing the script xyz.sh ??

Thanks,
Pradeep
# 2  
Old 11-04-2014
Quote:
Originally Posted by Pradeep_1990
Hi All ,

I'm running a script abc.sh in server "host1" shown as below :

Code:
#! /bin/bash

sh stop.sh

ssh user@$host2 "/home/user/prod_work/xyz.sh;

sh start.sh


The problem I am facing is , the control is not passed to host1 after executing the script "xyz.sh" in host2 .

How to exit the session in host2 after executing the script xyz.sh ??

Thanks,
Pradeep
is working ?
Code:
"/home/user/prod_work/xyz.sh;

# 3  
Old 11-04-2014
There's either one double quote too many or one too few... anyhow, the shell should complain.
# 4  
Old 11-04-2014
Sorry..I actually pasted the code wrong ..It is

Code:
ssh user@$host2 "/home/user/prod_work/xyz.sh"

But even then the issue remains .
# 5  
Old 11-04-2014
- what about contents of your script ?
Code:
# cat /home/user/prod_work/xyz.sh

- your ssh connection passwordless ?
# 6  
Old 11-04-2014
What do you mean by 'return control'? What do you expect to happen? What happens?
# 7  
Old 11-05-2014
Yes , the ssh connection is passwordless . I achieved that using the below :

SSH login without password

When I execute abc.sh in server "host1" , the shell script is executed till

ssh user@$host2 "/home/user/prod_work/xyz.sh" , but hangs after that . It does not continue to execute the next line (sh start.sh ) in host1 until I press Ctrl+C . That is what I mean by returning control .


Thanks,
Pradeep
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script connect to remote server, not find files and exit only from remote server, but not from scrip

I have a script, which connecting to remote server and first checks, if the files are there by timestamp. If not I want the script exit without error. Below is a code TARFILE=${NAME}.tar TARGZFILE=${NAME}.tar.gz ssh ${DESTSERVNAME} 'cd /export/home/iciprod/download/let/monthly;... (3 Replies)
Discussion started by: digioleg54
3 Replies

2. Shell Programming and Scripting

Remote script over ssh execution issues.

If I execute below code I am able to get string from column8 and column10 about a process. serverA1$> ps -ef | grep rotate | grep 'config' | awk '{print $8" "$10}' /<Oracle_home>/ohs/bin/odl_rotatelogs -h:/<app_Home>/config/OHS/ohs1/component_events.xml_ohs1... (12 Replies)
Discussion started by: kchinnam
12 Replies

3. Shell Programming and Scripting

How to Append the output of a script running in remote server to a file in local server?

Hi guys, So i am in server1 and i have to login to server 2, 3,4 and run some script there(logging script) and output its result. What i am doing is running the script in server2 and outputting it to a file in server 2 and then Scp'ing the file to server1. Similarly i am doing this for other... (5 Replies)
Discussion started by: srkmish
5 Replies

4. Solaris

Remote execution of a local script on multiple servers

So I have a scriptlet called solaris_command: for i in \ server1 server2 server3 do echo $i ssh $i $1 echo "" done I then use that as a command in multiple scripts to allow for data gathering for all virtual hosts in the environment thusly: solaris_command "cat... (3 Replies)
Discussion started by: os2mac
3 Replies

5. Shell Programming and Scripting

ssh - running remote command not exiting

Hi, i have a shellscript, where in i need to connect to different server start these three jobs and exit from the server and start the same three jobs on local server. ssh user@remotehost 'bash -s' << EOF ${GETT_HOME}/bin/start1 & sleep 10 ${GETT_HOME}/bin/start2 & sleep 10... (1 Reply)
Discussion started by: swapnabhargav
1 Replies

6. Shell Programming and Scripting

output from remote server during execution of a script

How to see the output from remote server during execution of a script ? I am executing a script (ls) from machine 1 but the o/p should be displayed in machine 2. Can I achieve this ? Example:- Machine 1:- # ls Machine 2:- (console) file1 file2 file 3 dir1 dir2 (0 Replies)
Discussion started by: frintocf
0 Replies

7. Programming

Perl script remote execution as another user

Hi gurus, I have a requirement where I need to remotely run a perl script as another user. Running the script locally as the required user is fine, however I need to su with the script due to filesystem permission issues. I do not want to update permissions on the remote server due to security... (5 Replies)
Discussion started by: melias
5 Replies

8. Shell Programming and Scripting

help with remote execution of a script

does anyone know how can i execute a script which i locally run as " . /etc/local/host/src.srvr -D ." need to execute above command in rexec command. if i put the command as it is it does not run. Sorry but i am naive in scripting. Thanks rexec sgplqim -l vau -n ' ' (0 Replies)
Discussion started by: NK4U
0 Replies

9. Shell Programming and Scripting

ssh can't back from remote host during script execution

Hi all I wrote a script to execute a script on several remote hosts, but somehow during the execution of the local script, ssh can't come back from the remote host, so that causes my local script hanging... I use the below command to do the job in the local script, any idea? ssh... (12 Replies)
Discussion started by: bzylg
12 Replies

10. Shell Programming and Scripting

problem with remote execution of script using telnet

Hi all, i am trying to remotely execute a script from a different server. this is the code that i use : #!bin/sh pwd (sleep 1 echo "username" sleep 2 echo "pwd" sleep 2 echo "cd /path/to/file" if then echo "script1.sh" echo "mailx -s "Task Executed"... (1 Reply)
Discussion started by: sais
1 Replies
Login or Register to Ask a Question