[SOLVED] Bash script unable to exit from shell after executing over SSH
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Yes.. That will work but the next commands on local script are executed without the completion of SSH execute command. I want to execute the next lines of script on my localhost once the ssh script is executed.
After starting all the servers on remote host, i will capture the status of each server in LOGFILE. If i place &, i am unable to get the status.
Code:
echo "#####################################"
echo "Starting All Servers" >> ${LOG_FILE}
echo "#####################################"
ssh ${appUsr}@${adminHost} "cd $svrscript; ls -ltr; ./startup_WL.sh start" >> ${LOG_FILE}
sleep 10;
echo "Servers are Starting.Please wait" >> ${LOG_FILE}
echo "################################"
echo " Server Status " >> ${LOG_FILE}
echo "################################"
ssh ${appUsr}@${adminHost} "cd $svrscript; ls -ltr; ./startup_WL.sh status" >> ${LOG_FILE}
Last edited by nareshreddyn; 09-11-2018 at 07:33 AM.
Remove the -f from that line because it sends the SSH client into the background just before command excution. So the client stays in the background and does not return. See "man ssh" for details.
What happens when you run "./startup_WL.sh status" by itself manually? Does it even exit? If it fails to exit, then the SSH client won't exit either when it runs it.
Guess the starting script might write some lines to the original standard output/error, before redirecting them to files,
and you want to save those lines.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.