[Tutor] Calling out to check on a server

dman dsh8290@rit.edu
Sun, 10 Feb 2002 12:39:43 -0500

On Fri, Feb 08, 2002 at 02:32:50PM -0500, McCarney, James Alexander wrote:
| Hail Pythonistas universal and triumphant,
| I seem to recall that there is a way (script) to check a server to see if it
| is alive. Maybe Vaults of Parnassus, but I didn't see it when I checked.

At what network layer do you want to check for life?

| Is anyone aware of something like that? Does anyone have something (code,
| tips, urls, whatever) they could share?

'ping' will tell you if the Network Layer is alive (for the Internet
this is the "IP" protocol).

| My platform Wind*** 2000; IIS server residing on another machine. Py 2.2

If you want to see if the Application Layer is alive (for example, to
see if IIS is actually responding to requests) then you must make a
request using the Application Layer protocol.  For HTTP (the protocol
IIS uses) the easiest way is

    import urllib
    urllib.open( "http://whatever/your/server/is/" ).read()

and if it throws an exception, the server (HTTP level, at least) is



Commit to the Lord whatever you do,
and your plans will succeed.
        Proverbs 16:3