[SOLVED] my shell Script stops after doing ssh to remote server
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
my shell Script stops after doing ssh to remote server
Could please anyone help me with my script! My Linux version is uname -a
Linux Hostname 2.6.18-164.6.1.el5 #1 SMP Tue Oct 27 11:28:30 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux
I have done the keygen part and while logging through script it doesn't ask for any password. But after doing ssh, the scripts just logs into the remote server and not processing further. My script goes likes this.....
if [ "$retVal" -eq "0" ]; then
cd /apps ;
echo 'Script Completed' ;
Basically it's not able to get into the /apps path.
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Isn't the problem here that the script is running on the local host, so once you ssh into the remote host it suspends until you return? At least that's what happens when I try this.
Edit: I was wondering how this could be done myself and I came across this, which may be useful: http://stackoverflow.com/questions/3...remote-machine
@catkin, nice thought, but still it didn't worked.
The ssh command is opening a new shell. Your script is still stuck in the old shell running the ssh command.
Think about it this way...
If you were at the terminal, and typed ssh, you would then be connected to the other computer. You could then do whatever you wanted, run whatever you wanted, etc. When you typed "exit", your ssh command would end and it would drop you back to the previous shell. THIS is what your script is waiting for. At this point your script would run its next command, "retVal=$?".
Your script will not continue on to the retval, or the cd, etc., until the ssh command has terminated. The ssh command will not terminate until you FINISH whatever it is you are doing on the other machine and return back to the original terminal.
Your script is not stopping or getting stuck after running the ssh, it's simply waiting for the ssh to exit so that it can continue running the script.
Hopefully that makes sense.
Last edited by suicidaleggroll; 05-11-2012 at 10:54 AM.