Note that there are some explanatory texts on larger screens.

plurals
  1. POAutomate telnet port testing on Windows 7 using batch script
    primarykey
    data
    text
    <p>I am using Windows 7 x64. Using a bat script, I need to check whether I am able to connect to some specific ports on a server using telnet. If successfully connected, the server displays a menu, or else a message like this : Connecting To xxxxx...Could not open connection to the host, on port xxxxx: Connect failed. </p> <p>For my purpose, the server has several ports to be tested and I don't want to complicate things by logging in or navigating menus. I just want a simple output indicating whether the connection was successful or not. Checking for exit status didn't work. I don't want to use Visual Basic. Any idea how check the connection status using a bat script? Currently I check visually and I use the below script to open connections</p> <pre><code>@ECHO OFF setlocal EnableDelayedExpansion echo. SET /P host_name="Please enter the hostname: " echo Please enter the port numbers followed by the Enter key: echo. set num=0 :Loop set /a num=num+1 SET /P mwa_port%num%="" if "!mwa_port%num%!"=="" (goto Start) goto Loop :Start set /a num=num-1 for /L %%i in (1,1,%num%) do ( echo Trying to log into port !mwa_port%%i! of %host_name% start /min "" "C:\Windows\System32\telnet.exe" %host_name% !mwa_port%%i! REM echo Exit Code is %errorlevel% ) :End endlocal echo. SET /P leave="Press any key to exit.." </code></pre> <p>Here is a sample output of the script : </p> <pre><code>Please enter the hostname : abcdefg.hijkl.mnop Please enter the port numbers followed by the Enter key: 10001 10002 10003 10004 10005 Trying to log into port 10001 of abcdefg.hijkl.mnop Trying to log into port 10002 of abcdefg.hijkl.mnop Trying to log into port 10003 of abcdefg.hijkl.mnop Trying to log into port 10004 of abcdefg.hijkl.mnop Trying to log into port 10005 of abcdefg.hijkl.mnop Press any key to exit.. </code></pre> <p>It then opens 5 telnet windows in minimized state, each one with a menu on successful login</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload