Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2004-08-23
1
Medium Priority
?
2,966 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:Pedro Keson
1 Comment
 
LVL 7

Accepted Solution

by:
rhrowson earned 500 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Here are the symptoms: You start receiving calls from users that one of your legacy web apps isn't coming up, so you log into your IIS 5 server to check it out.  When you pull up the services, you notice that the WWW Publishing service isn't runn…
Today I came across an interesting issue that had me pulling my hair out.  I was troubleshooting a new internal web site which uses integrated security instead of anonymous.  When browsing the site from my laptop, I was able to access it with no iss…
Integration Management Part 2
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

783 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