Question : Problem: Telnet Script to Test Connectivity

HI,
I am having some connectivity issue to a remote host and would like to be able to make a scheduled task that tests connectivity via telnet. Basically, it would run every 5 minutes (terminate after 60 seconds if successful) and if it fails, it would output a message to a txt file on the local machine. I have a remote monitoring tool that sniffs for this error entry every 5 minutes.

Breakdown
Every 5 minutes - telnet remote.host 8075
If success, connection closes after 60 seconds untl the next test.

If it fails, it will output "Connection to host failed" to a txt file on the local machine.

I am having problems getting a start on this, mainly the scripting to close the connection after 60 seconds. I do not want 100+ open telnet tests at the end of the day. Any assistance is greatly appreciated.

Thanks!

Answer : Problem: Telnet Script to Test Connectivity

If you just want to check if you check if the port is opened/closed, you can download portqry from
http://www.microsoft.com/downloads/details.aspx?FamilyID=89811747-C74B-4638-A2D5-AC828BDC6983&displaylang=en

Copy the sample below into notepad and save it as *.cmd
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
@echo off
if "%1"=="" goto _help
if "%2"=="" goto _help
 
REM 0=success, 1=failure
portqry -n %1 -e %2 -q
 
IF ERRORLEVEL 1 GOTO _closed
:_opened
	REM handler for open port
	echo. SUCCESS: Port is OPENED
	goto _eof
 
:_closed
	REM handler for closed port
	echo. FAILURE: Port is CLOSED
	goto _eof
 
:_help
	echo.
	echo. Test if port is open
	echo.
	echo. Syntax:
	echo.
	echo. 	%0 hostname port
	echo.
 
:_eof
Open in New Window Select All
Random Solutions  
 
programming4us programming4us