How to use batch processing to resolve the input of the bulk telnet command

Source: Internet
Author: User

The telnet command does not work automatically, because if Telnet is successful, Telnet controls the input.
In fact, not so troublesome, you download a Microsoft Official scanner called PortQry, with a for read in your file IP and port, execute on the line.
Suppose your file is called List.txt, which is in the format of IP port, so write:
@echo off
@setlocal enabledelayedexpansion
@if exist notopen.log del/f/q Notopen.log
@if exist open.log del/f/q Open.log
@for/F "tokens=1,2* delims="%%i in (list.txt) does (
@portqry-N%%i-e%%j|find "not" >nul
@if%errorlevel%==0 (
@echo%%i:%%j not open >>notopen.log
) Else (
@echo%%i:%%j is open >>open.log
)
)
Save the above batch as Myscan.bat, and your list file, and the PortQry tool in a folder. After running batch processing, the pass is saved to the Open.log, and the notopen.log is not stored.

Ask:
Thank you very much, I tested your method result, the result is a flash black box is gone. Also did not produce open.log and notopen.log these two files, is not where I write wrong. The biggest possible is not my IP format in the list.txt is incorrect. I wrote it.
172.27.193.1 2000
172.27.193.2 2000
172.27.193.3 2000
Such a format. If not, what kind of IP format should I write?

Chase Answer:
Not your format is wrong, I am careless, sorry. Give you a paragraph from the hair, this is the actual test under XP.
@echo off
@setlocal enabledelayedexpansion
@if exist notopen.log del/f/q Notopen.log
@if exist open.log del/f/q Open.log
@for/F "tokens=1,2* delims="%%i in (list.txt) does (
@portqry-N%%i-e%%j|find ": LISTENING" >nul
@if!errorlevel!==0 (
@echo%%i:%%j >>open.log
) Else (
@echo%%i:%%j >>notopen.log
)
)
You try again. However, when the address port is not available, my machine each address has about 60 seconds time-out interval, so if there are many machines do not boot, the efficiency is not too high.

There is a solution, is to first use for the loop ping again, Ping Pass the scan, I also give you a simple batch processing, called Myping.bat Bar.
@echo off
@setlocal enabledelayedexpansion
@if exist ping_ok.txt del/f/q ping_ok.txt
@for/F "tokens=1,2* delims="%%i in (list.txt) does (
@ping-N 1%%i|find "ttl=" >nul
@if!errorlevel!==0 @echo%%i%%j >>ping_ok.txt
)
After this execution, the ping_ok.txt will be generated, and the first batch of list.txt can be replaced with this ping_ok.txt on the line. The problem with this solution is that if your client has a firewall, or a network packet loss rate, then the ping is not successful, it may be false, you do not use the scheme.

How to use batch processing to resolve the input of the bulk telnet command

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.