中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-09-23 13:03
47,812 topics / 349,917 posts / today 0 new / 48,273 members
DOS批处理 & 脚本技术(批处理室) » Seeking help [Write a batch script to check if the telnet remote port is open]
Printable Version  3,286 / 3
Floor1 wangsuiri Posted 2008-05-26 11:19
新手上路 Posts 1 Credits 4
To check whether ports such as 22, 1521 on remote Linux platforms (multiple remote servers) are open by using telnet xxxx 22 /telnet xxx 1521 on this machine (Windows XP) and print the results to a file. How to write a batch script?
Floor2 vkill Posted 2008-05-26 19:58
金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽
Floor3 wiq Posted 2017-04-10 13:28
初级用户 Posts 35 Credits 179
'nc' is not an internal or external command
Floor4 goltaxhs Posted 2017-08-26 21:03
新手上路 Posts 8 Credits 8
Let's try.

@echo off
set remoteip=1.1.1.1

:start
echo,
set port=
set /p port=Enter test port:
IF %PORT% LSS 0 goto erroe
if %PORT% GTR 65535 goto erroe
telnet %remoteip% %PORT% >nul 2>nul
if %errorlevel% ==0 (echo %remoteip%:%PORT% port service is normal.) else (echo %remoteip%:%PORT% port service is abnormal.)
echo %date% %time%>telnetlog.txt
echo %remoteip%:%PORT% port service is normal>>telnetlog.txt
echo, >>telnetlog.txt
pause
exit

:error
ECHO Port out of range
echo Re-enter a legal port
pause
goto start

[ Last edited by goltaxhs on 2017-8-26 at 21:16 ]
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023