參考: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
使用這種方式可以將標准輸出和標准錯誤重定向到文件中,通過分析文件的內容來判斷端口打開狀態