简体   繁体   English

如何隐藏shell命令的特定标准输出

[英]how to hide specific standard output of shell command

I am doing ssh of a "if statement" to a remote server. 我正在向远程服务器执行“ if语句”的ssh。

Example: 例:

========== Start of Script======== ==========脚本开始========

#!/bin/sh

CMD='if [ ! CMD ='if [! -d "/user/directory" ]; -d“ /用户/目录”]; then echo -e "user directory missing"; 然后回显-e“用户目录丢失”; else echo -e "present"; 否则echo -e“ present”; fi; 网络连接;

ssh remoteserver "$CMD" 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. 运行此脚本时,我从远程服务器收到欢迎消息,然后从if条件给出消息。 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..... :/ root> ./script.sh警告声明这是一个受保护的网络,如果您未经授权....

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/ 您可以在此处查看其他解决方案, 网址为http://www.linuxquestions.org/questions/linux-security-4/how-do-you-turn-off-login-banner-for-non-interactive-ssh-470516/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM