Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
#!/bin/bash

ssh -t $SSH "
    some
    commands
"

Where is the 'connection to xx.xxx.xx.xxx closed' message coming from? I can't stop it even with result=ssh ...

share|improve this question
up vote 2 down vote accepted

That is coming from SSH. You see it because you gave the -t switch, which forces SSH to allocate a pseudo-terminal for the connection. Traditionally, SSH displays that message to make it clear that you are no longer interacting with the shell on the remote host, which is normally only a question when SSH has a pseudo-terminal allocated.

share|improve this answer

As Fran mentioned, this is coming about because of the -t switch. You can hide the message by appending:

 2> /dev/null

Your code would look like this:

#!/bin/bash

ssh -t $SSH "
    some
    commands
" 2> /dev/null

This redirects STDERR to /dev/null. Keep in mind all error messages that may be raised will also be redirected to /dev/null and so will be hidden from view.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .