shell脚本 telnet检查端口是否通

参考:https://blog.csdn.net/signjing/article/details/69535226

正常的情况

$ echo "" | telnet 101.199.97.65 62715
Trying 101.199.97.65...
Connected to 101.199.97.65.
Escape character is '^]'.
Connection closed by foreign host.

不正常的情况

$ echo "" | telnet 101.199.97.65 62715
Trying 101.199.97.65...
telnet: connect to address 101.199.97.65: Connection refused

使用这种方式可以将标准输出和标准错误重定向到文件中,通过分析文件的内容来判断端口打开状态

原文地址:https://www.cnblogs.com/faberbeta/p/13564553.html