Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.
#!/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
add comment

2 Answers

up vote 1 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
add comment

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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.