Telnet batch Processing

Source: Internet
Author: User
Tags server port

Need to confirm that more than one server port is open, if a telnet will be very troublesome, through Baidu, wrote two bat, basic can do the job needs.

Start.bat

Start "" "E:\telnet\telnet.bat" 192.168.192.7
Start "" "E:\telnet\telnet.bat" 192.168.192.8
Start "" "E:\telnet\telnet.bat" 192.168.192.9
Start "" "E:\telnet\telnet.bat" 192.168.192.10
Start "" "E:\telnet\telnet.bat" 192.168.192.11
Start "" "E:\telnet\telnet.bat" 192.168.165.7
Start "" "E:\telnet\telnet.bat" 192.168.165.8
Start "" "E:\telnet\telnet.bat" 192.168.165.9
Start "" "E:\telnet\telnet.bat" 192.168.165.10
Start "" "E:\telnet\telnet.bat" 192.168.165.11

Telnet.bat

C:
CD C:\Windows\System32
Set kong=0
REM Telnet 10.176.163.4 9999
Telnet%1 8443
rem If%errorlevel% neq%kong%
Exit

Echo%errorlevel%

which

1.%errorlevel% expresses the return value of the previous command.

2. However, because the start command is used to open Telnet.bat, the%errorlevel% here does not work. Reasons not found.

3. If Telnet is not possible, the black window will be turned off for about 20 seconds. After 20 seconds, check the title bar on the black window that is not turned off, and the IP that appears is the Telnet machine.

4. Extended----bat to pass more than 10 parameters

The parameters that can be referenced in a batch file are%0~%9,%0 refers to the batch file itself, or an external command, and%1~%9 is a batch parameter, also called a formal parameter, and if the argument of the replacement parameter exceeds the value specified in the batch file (9) and you want to apply the arguments to the batch file, The shift command can help you achieve it!

Shift command: Change the location of replaceable parameters in a batch file
C code
Shift [/n]
Shift [/n]n value is [0,8], and is an integer; [/n] is an optional parameter, when n is given a value, it means that the command is shifted from the nth parameter, and when n is given a value of 0, 1, or shift without any command option, the substitution parameter in the batch file moves left one position, Subsequent replacement parameters are filled in succession until the replaceable parameter is empty.

Eg: create batch file D:\test.bat; C code

Copy the code code as follows:
@echo off
Cls
Echo%1%2%3%4%5%6%7%8%9
shift/0
Echo%1%2%3%4%5%6%7%8%9
Shift/1
Echo%1%2%3%4%5%6%7%8%9
Shift/2
Echo%1%2%3%4%5%6%7%8%9
Shift/3
Echo%1%2%3%4%5%6%7%8%9
Shift/4
Echo%1%2%3%4%5%6%7%8%9
Shift/5
Echo%1%2%3%4%5%6%7%8%9
Shift/6
Echo%1%2%3%4%5%6%7%8%9
Shift/7
Echo%1%2%3%4%5%6%7%8%9
Shift/8
Echo%1%2%3%4%5%6%7%8%9
Pause 1>nul
@echo offclsecho%1%2%3%4%5%6%7%8%9shift/0echo%1%2%3%4%5%6%7%8%9shift/1echo%1%2%3%4%5%6%7%8%9s Hift/2echo%1%2%3%4%5%6%7%8%9shift/3echo%1%2%3%4%5%6%7%8%9shift/4echo%1%2%3%4%5%6%7%8%9shift /5echo%1%2%3%4%5%6%7%8%9shift/6echo%1%2%3%4%5%6%7%8%9shift/7echo%1%2%3%4%5%6%7%8%9shift/8ech O%1%2%3%4%5%6%7%8%9pause 1>nul

then enter Test 1 2 3 4 at the command prompt d:\. 17 Show execution results and know the rules! C code
D:\>test 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17

1 2 3 4 5 6 7 8 9
2 3 4 5 6 7 8 9 10
3 4 5 6 7 8 9 10 11
3 5 6 7 8 9 10 11 12
3 5 7 8 9 10 11 12 13
3 5 7 9 10 11 12 13 14
3 5 7 9 11 12 13 14 15
3 5 7 9 11 13 14 15 16
3 5 7 9 11 13 15 16 17
3 5 7 9 11 13 15 17

Telnet batch Processing

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.