Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How to ping/connect to port (SMTP) and receive answer

Posted on 2004-08-23
1
2,954 Views
Last Modified: 2008-01-09
Hi there,

Now standing in front of quite nice piece of work. I am supposed to write a small ASP code (which will be running on intranet IIS system), which will allow users to preview an application server status. I might use components as well, but just do not know, where to start.

I need to have some code snippets which will:
* allow me to run a ping from web server and show results (available/NOT available)
* allow me to connect to a specified server port, send there something and receive a response
   (to check the service availability)
* etc.

Is this possible? Any ideas? web links are OK, you do not need to write a lot, just say... man, you are crazy, it is not possible.... or say yep, just use this and this...


Thanks a lot.

Bye
Petr

0
Comment
Question by:keson
1 Comment
 
LVL 7

Accepted Solution

by:
rhrowson earned 125 total points
ID: 11873142
I have a vbscript that does this in conjunction with a text file. It polls for the presence of a particular page. You could modify the page it calls to send an e-mail:

Script:

Dim varTestURL
Dim varSiteName
Dim varTestURLLength
Dim varSiteNameLength
Dim varFS
Dim varInputFile
Dim varOutputFile



Set varFS=CreateObject("Scripting.FileSystemObject")
Set varInputFile = varFS.OpenTextFile("C:\WebServers.txt",1,True)




Do While Not varInputFile.AtEndOfStream
   



varTestURL=varInputFile.ReadLine



'varTestURL="http://phone/server_info.asp"
varTestURLLength=Len(varTestURL)
varSiteNameLength=InStr(8,varTestURL,"/",1)
varSiteName=Mid(varTestURL,8,(varSiteNameLength-8))
'MsgBox varSiteName
Set xmlHTTP = CreateObject("Microsoft.XMLHTTP")

xmlHTTP.Open "GET", varTestURL, False

xmlHTTP.Send
'WScript.Echo "Server Response: " & xmlHTTP.Status
If xmlHTTP.Status=200 Then
'MsgBox "OK", vbOK

'WScript.Echo
'WScript.Echo "Headers"
'WScript.Echo "======="
'WScript.Echo xmlHTTP.GetAllresponseHeaders
'WScript.Echo
'WScript.Echo "HTML"
'WScript.Echo "======="
'WScript.Echo xmlHTTP.responseText
Elseif xmlHTTP.Status<>200 Then
'       MsgBox"Panic",vbcritical
       
       
        MsgBox varSiteName & " is down"
        Set varOutputFile=varFS.OpenTextFile("C:\WebServers1.txt",8,True)
        varOutputFile.writeline(varSiteName & " Is down " & Date & " "& Time)
        varOutputFile.Close
End If

Set xmlHTTP = Nothing

Loop

You will need to create the text file and each line should look like this:

http://test/server_info.asp

the page could be an SMTP test page
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Debug Tools to analyse IIS process: This article focus on taking memory dumps from IIS to determine which code is taking more time and to analyse which calls hangs/causes more CPU usage. To take dumps,download the following. Install1: To st…
Lync server 2013 or Skype for business Backup Service Error ID 4049 – After File Share Migration
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question