0

I am doing ssh of a "if statement" to a remote server.

Example:

========== Start of Script========

#!/bin/sh

CMD='if [ ! -d "/user/directory" ]; then echo -e "user directory missing"; else echo -e "present"; fi;

ssh remoteserver "$CMD"

==========End of script==========

Query:

While running this script ,I get welcome message from remote server and then the message given by my if condition. I do not wish to receive the welcome message from remote server. What can be done to supress that ?

example:

:/root> ./script.sh Warning Notice This is a protected network,and if you are not authorized.....

1
  • I have already tried > /dev/null 2>&1 but its also supressing my message from if statement. Commented Jun 17, 2014 at 14:03

1 Answer 1

1

I think you can try:

    ssh -o LogLevel=Error <rest of cmd>

or

    ssh remoteserver 'remotecommand args ... 2>&1' 2>/dev/null

which will only removes the welcome message.

You can check other solutions in here http://www.linuxquestions.org/questions/linux-security-4/how-do-you-turn-off-login-banner-for-non-interactive-ssh-470516/

Sign up to request clarification or add additional context in comments.

1 Comment

I am glad that helps. Please mark this as the answer so others would know.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.