Implementation method of batch parallel Telnet end-to-end port in Linux

Source: Internet
Author: User

The following is an example of Telnet to port 22

Station91:~/shell/telnet_port # pwd

/root/shell/telnet_port

Station91:~/shell/telnet_port # Cat Telnet_port.sh

#!/bin/bash

RM telnet_result.txt >/dev/null 2>&1

Port_22=22

For I in $ (cat ip.list)

Do (telnet $i $PORT _22< >telnet_result.txt &) >/dev/null 2>&1

#加 & Let it execute in parallel, >>telnet_result.txt logs during Telnet

Quit

Eof

Done

Cat Telnet_result.txt | Grep-b 1] | grep [1-9] | awk ' {print $} ' | Cut-d '. '-F 1,2,3,4 > Telnet_alive.txt

Cat Ip.list Telnet_alive.txt | Sort | Uniq-u > Telnet_die.txt

Station91:~/shell/telnet_port # for I in {88..93};d o echo "192.168.14. $i" >>ip.list;done #使用for循环得到需要telnet主机的ip

Station91:~/shell/telnet_port # Cat Ip.list

192.168.14.88

192.168.14.89

192.168.14.90

192.168.14.91

192.168.14.92

192.168.14.93

Station91:~/shell/telnet_port # ls

Ip.list telnet_port.sh

Station91:~/shell/telnet_port #./telnet_port.sh &

[1] 16848

Station91:~/shell/telnet_port # ls

Ip.list telnet_alive.txt telnet_die.txt telnet_port.sh telnet_result.txt

[1]+ done./telnet_port.sh

Station91:~/shell/telnet_port # Cat Telnet_alive.txt//from native Telnet to port 22 port can telnet through only 192.168.14.91

192.168.14.91

Station91:~/shell/telnet_port # Cat Telnet_die.txt

192.168.14.88

192.168.14.89

192.168.14.90

192.168.14.92

192.168.14.93

Station91:~/shell/telnet_port # Cat Telnet_result.txt//logging log format

Trying 192.168.14.91 ...

Connected to 192.168.14.91.

Escape character is ' ^] '.

Trying 192.168.14.88 ...

Trying 192.168.14.89 ...

Trying 192.168.14.90 ...

Trying 192.168.14.92 ...

Trying 192.168.14.93 ...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.