其他分享
首页 > 其他分享> > 批量telnet服务端口

批量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 '^]'.

  

标签:...,begin,批量,character,端口,telnet,host,10.10
来源: https://www.cnblogs.com/last-one/p/15993118.html