星期四, 10月 31, 2013

[Shell script] 偵測remote host tcp port 是否有開啟

PORT=1186

SERVER=mgt

 

===============================================================

ck_mgt()

{

l_TELNET=`echo "quit" | telnet $SERVER $PORT | grep "Escape character is"`

if [ "$?" -ne 0 ]; then

  echo "Connection to $SERVER on port $PORT failed"

  exit 1

else

  echo "Connection to $SERVER on port $PORT succeeded"

fi

}

ck_mgt

===============================================================

沒有留言:

LinkWithin-相關文件

Related Posts Plugin for WordPress, Blogger...