How to exit from a server?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to exit from a server?
# 1  
Old 02-12-2014
How to exit from a server?

Hi,

I am on unix serverA where i have a script called A.sh

Code:
more A.sh
echo "Hello"
ssh user1@serverB
echo "Welcome"

After the ssh takes me to serverB; i execute a script on serverB called B.sh
Code:
more B.sh
echo " You are serverB"
exit
exit

With the two exit statements on serverB i was expecting that the control would comeback to serverA and that i would exit from serverB. But that did not happen and i had to manually type exit twice to come back to serverA where it then printed Welcome
# 2  
Old 02-12-2014
Which is quite normal as of the little content of b.sh ... int other words it exited on the first exit as we would suppose it should have done and second is never executed...
# 3  
Old 02-12-2014
So, how can i get it to exit from the server.
# 4  
Old 02-12-2014
Quote:
After the ssh takes me to serverB; i execute a script on serverB called B.sh
How? Where?
We see nothing in what you have submitted so we cant help...
# 5  
Old 02-12-2014
If your command/script is part of your ssh command, then when the command/script finishes, so will the ssh and you will be back at ServerA

Consider a script on ServerA
Code:
echo "Runs on `hostname`"
ssh ServerB hostname
echo "Back on `hostname"

Does that help, or have I missed the point?

You should get the output:
Code:
ServerA
ServerB
ServerA

Robin
# 6  
Old 02-12-2014
Quote:
Originally Posted by vbe
How? Where?
We see nothing in what you have submitted so we cant help...
After the script A.sh of serverA helps me ssh to ServerB; i manually execute the script on serverB i.e. ./B.sh. What do i have to code inside the B.sh so that it helps exit from serverB back to A.sh on serverA
# 7  
Old 02-12-2014
IF you manually type ./B.sh when it finishes its back to the prompt, where you type exit.. I have not ime for testing now... but you could try
Code:
./B.sh ;exit

or
Code:
 ./B.sh && exit

This User Gave Thanks to vbe For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

9 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

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

3. Debian

How to exit debian server terminal?

I have an situation that are quite strange to me. I am not able to exit the server terminal and enter back into my home computer terminal by the command exit like I used to be able to exit the server terminal with before. I end up into my root shell again without even typing the root password like... (6 Replies)
Discussion started by: Jonathan Sander
6 Replies

4. Shell Programming and Scripting

Need the difference between exit 1 & exit 7

Hi In one of the script I am seeing some thing like exit 7,exit 1,exit 2,exit 3,exit 9,exit6.What is the difference between all of this exit.Can anyone help here please (3 Replies)
Discussion started by: ginrkf
3 Replies

5. Shell Programming and Scripting

How to exit prompt when starting a weblogic administration server remotely?

Hi, I am trying to start Weblogic Admin server using start-up script (./startWeblogic.sh) from a remote host using a different user. The server starts fine but prompt is stuck, it does not return Background: We have multiple admin servers in different environment and the requirement is all... (4 Replies)
Discussion started by: bhaskar_m
4 Replies

6. Shell Programming and Scripting

Need help on how to exit a script run on a server from a remote server

hi, I am using the below line to run a script from remote server(say server A) to another server(say server B). ssh username@servername ksh script name. The issue is the script logs into server B, executes the script on server B, transfers the file to server A but does not exit from... (4 Replies)
Discussion started by: yohasini
4 Replies

7. UNIX for Dummies Questions & Answers

what is meaning of exit(0) and exit(1)

can u tell me what is the meaning of exit(0),exit(1),exit(2) what is diff amonng these. Amit (1 Reply)
Discussion started by: amitpansuria
1 Replies

8. Shell Programming and Scripting

SSH to a server and exit out

Hi, Can someone please help me in resolving this issue - I am doing SSH from a server 1 to another server 2 and executing some statements there and then automatically exit out of second server to the first where script was getting executed. Can you please help me script this code ? Thanks (3 Replies)
Discussion started by: rajpuneyani
3 Replies

9. UNIX for Dummies Questions & Answers

Where can I find a list of exit codes? (Exit code 64)

I'm receiving an exit code 64 in our batch scheduler (BMC product control-m) executing a PERL script on UX-HP. Can you tell me where I can find a list of exit codes and their meaning. I'm assuming the exit code is from the Unix operating system not PERL. (3 Replies)
Discussion started by: jkuchar747
3 Replies
Login or Register to Ask a Question