I am calling a script via ssh client like this:
ssh root@host "su - oracle -c '~/bin/weblogic start'"
The ~/bin/weblogic
is a bash script that actually starts the web server in the background and reads and displays its log until certain pattern is found ('Server state changed to RUNNING') at which point it exits. When I call it from the remote location, it hangs after the last bash command is executed. I am sure it has something to do with what is explained at SO (https://stackoverflow.com/questions/8122780/exiting-shell-script-with-background-processes); however, I can't start weblogic
bash script in the background – I must wait for it to finish and get its exit code along with regular stdout up to the specific pattern.
The bash code is like this:
function start_server {
~/bin/weblogic.py
echo 'Python script finished'
exit 1
}
....
start_server
The output is
... server output ...
...
... Server state changed to RUNNING ....
Python script finished
How can I make SSH client return? I am running this on Solaris 11.3.
exit 1
command right afterecho 'Python script finished'
command, denotes an unsuccessful completion. I am just thinking out loud here but your main script might have a error handling mechanism, which is not letting go the control of your ssh session, because of this erroneous exit code. Did you try with plainexit
orexit 0
? – MelBurslan Jun 27 '16 at 22:02nohup
without any luck. The gist is here: gist.github.com/majkinetor/4896b9f6c85cc5822bc4b5103ea09f83 – majkinetor Jun 28 '16 at 7:29