Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

script to see if server can access a website

Status
Not open for further replies.

wciccadmin

Programmer
Jan 26, 2006
17
US
Hello,

I want to use a vbscript to check if a server can access the internet. I am not sure the best way to go about this.

I was thinking of using the winhttp object and hit a few big sites like google yahoo etc. At this point I am stuck on what to do.

I thought about putting the page source in to a string variable and then searhing for a keyword like yahoo on yahoo's site, google on googles etc etc.

If it finds the key word on at least one of the sites, we will assume the server can access the internet.

It seems a little archaic, I don't know if this is the best way or even a decent way of going about this.

Any ideas would be greatly appreciated.

Thanks
 
Here is how I check to see if one of my sites is up and running.

Code:
'==========================================================================
'
' NAME: LinkChecker.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: [URL unfurl="true"]http://www.TheSpidersParlor.com[/URL]
' COPYRIGHT (c) 2006 All Rights Reserved
' DATE  : 6/13/2006
'
' COMMENT: 
'
'
'    THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
'    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED To
'    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
'    PARTICULAR PURPOSE.
'
'    IN NO EVENT SHALL THE SPIDER'S PARLOR AND/OR ITS RESPECTIVE SUPPLIERS 
'    BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
'    DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
'    WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
'    ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
'    OF THIS CODE OR INFORMATION.
'
'==========================================================================
Dim oFSO
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oTextStream = oFSO.OpenTextFile("sourcetocheck.htm")
'make an array from the data file
CodeList = Split(oTextStream.ReadAll, vbNewLine)
'close the data file
oTextStream.Close
LiveLink = "Dead Link"
For Each Line In CodeList
  If InStr(1,Line,"isitthere.htm") Then
     LiveLink = "Live Link"
  End If
Next
WScript.Echo LiveLink

Just point it to read an html file and search for a known url link as I do above. I suggest you put a web page out on your Internet site for this that is not linked to from the rest of the site, just so you can use it for this purpose.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
 
Thanks, that is what I was thinking. I will plan on checking an array of a few of the big sites like msn or yahoo and if it connects to at least one... we will assume the machine can access the net.

thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top