Skip to content
Advertisement

ssh does not return even after execution

The following ssh command does not return to terminal. It hangs though the execution is completed. The execution hangs after echo hi command.

JavaScript

Output

JavaScript

ciInstallAndRun.sh

JavaScript

Source OS: Redhat Dest Os: Solaris 10 8/07

Any idea to fix this.

Advertisement

Answer

Any idea to fix this.

Your installation script has spawned a child process.

Add a ps -f or ptree $$ command before echo hi. You’ll see a child process or multiple child processes spawned by your install script.

To stop the SSH command from hanging, you need to detach such child process(es) from your terminal’s input/output. You can sedirect your script’s output to a file – both stdout and stderr with > /some/output/file 2>&1, and also redirect its input with < /dev/null.

Or you can use the nohup command.

You haven’t provided an MCVE, as others have noted, but this is likely the problem command in you install script, since your question implies that you see the expected output from your install script:

JavaScript

You probably would do better to replace it with something like:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement