user2809888
user2809888

Reputation:

how to hide specific standard output of shell command

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.....

Upvotes: 0

Views: 501

Answers (1)

CS Pei
CS Pei

Reputation: 11047

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/

Upvotes: 1

Related Questions