SSH not closing after script exit

From: Arnoud Smit (lagoonNOSPAM@xs4all.nl)
Date: 03/28/02


From: Arnoud Smit <lagoonNOSPAM@xs4all.nl>
Date: Thu, 28 Mar 2002 12:46:07 GMT

Got the following over here.. really bugs us..

We've got some remote machines to administer, so we have a SSH to a
remote server, over which we connect to the machine to administer. We
created a script which takes care of the SSH connection; works fine.. On
the remote server we start a script which does a 'sleep 10' after which
the script exits, which works fine 2 offcourse. Now for the tricky
stuff..

When we start the local script, the one which creates the SSH, with an
'&' (to be able to have all the commands in one go..) the connection is
established over SSH, but never closes.. Even if the script on the other
side does an exit..

Weird..

Our assumption is that the fork to the new shell (&) starts the script,
which starts the SSH (still following me?), which exits after the SSH
gets active (new shell?). Thus, is the SSH a new shell and is the forked
shell exited? This might explain why the SSH connection to the remote
server stays open while there are no processes running on either site
using the SSH.

When we don't use the & in the initial shell, the problem doesn't occur..

Bizarre...

Any hints, tips etc welcome..

Arnoud
Open-Challenge



Relevant Pages

  • Checking for existence of command prior to execution
    ... alone in an interactive shell it works though. ... it will fail if I add ssh to the list of commands which is ... aliased by the tcsh that is calling the above script. ...
    (comp.os.linux.misc)
  • Re: spawn sh -c "ssh -T $host -l $user <$JOBSCRIPT" #HowCanI elim sh?
    ... Notice that the remote script is supplied as the STDIN to ssh. ... OK then I can stick to bash, or a smaller shell. ... I'm using the expect script as a wrapper/launcher for cygwin ...
    (comp.lang.tcl)
  • RE: Help with SSH
    ... OK before you ask your script to do it's thing. ... Subject: Help with SSH ... a command through ssh on a remote server. ... public keys and have copied the public key to the remote server to the ...
    (RedHat)
  • Re: Remote SSH
    ... into account the fact that a remote server may be down ... action and/or move on in the script. ... "man ssh", but nothing jumped out at me. ...
    (comp.unix.solaris)
  • Re: Remote SSH
    ... ssh, that when using it in a script, takes into account the fact that ... a remote server may be down or just not accessible, ... I ran a "man ssh", but nothing jumped out at me. ...
    (comp.unix.solaris)