批量telnet服务端口
当某个服务需要访问比较多的服务时,需要检查端口是否打通。可以使用如下脚本
注意:
1、当某个端口不通时,程序会停止运行。
例子:
--服务器列表 cat host.txt [xxxxxxx@xxxxxxxx ~]$ cat host.txt 10.10.10.10 50000 10.10.10.10 443 --脚本 #!/bin/bash while read line do sleep 1 echo "================begin telnet >>>$line=========================" echo "exit" | telnet $line sleep 1 done < host.txx
--运行过程:
================begin telnet >>>10.10.10.10 50000=========================
Trying 10.10.10.10...
Connected to 10.10.10.10.
Escape character is '^]'.
Connection closed by foreign host.
================begin telnet >>>10.10.10.10 443=========================
Trying 10.10.10.10...
Connected to 10.10.10.10.
Escape character is '^]'.
Connection closed by foreign host.
================begin telnet >>>10.10.10.10 443=========================
Trying 10.10.10.10...
Connected to 10.10.10.10.
Escape character is '^]'.