无法正确 grep telnet 输出

无法正确 grep telnet 输出

我正在编写一个脚本来验证多个外部系统的连接,超时时间为 10 秒。如何避免此脚本中的“连接被外国主机关闭”文本。我只为转义文本执行 grep 但由于某种原因“连接被外部主机关闭”这也得到输出

   [MASKED@MASKED scripts]$ ./test1.sh
    Bloomerberg1 Failed
    Connection closed by foreign host.
    Scorecardgrid Successful
    Sewa Failed
    
    This is coming for all Successful connectivity. 
    
    #!/bin/bash
    RED='\033[0;31m'
    NC='\033[0m' # No Color
    
    echo quit | timeout --signal=9 10 telnet   HOSTNAMEMASKED PORTMASKED | grep -i escape 1>/dev/null 2>/dev/null
    
    if [ "$?" == "0" ]
    then
       echo "Bloomerberg1 Successful"
    else
       echo -e "${RED}Bloomerberg1 Failed${NC}"
    fi
    
    echo quit | timeout --signal=9 10 telnet  HOSTNAMEMASKED PORTMASKED | grep -i escape 1>/dev/null 2>/dev/null
    
    if [ "$?" == "0" ]
    then
       echo "Scorecardgrid Successful"
    else
       echo -e "${RED}Scorecardgrid Failed${NC}"
    fi
    
    echo quit | timeout --signal=9 10 telnet  HOSTNAMEMASKED PORTMASKED  | grep -i escape 1>/dev/null 2>/dev/null
    
    
    if [ "$?" == "0" ]
    then
       echo "Sewa Successful"
    else
       echo -e "${RED}Sewa Failed${NC}"
    fi

相关内容