Mental Jetsam

By Peter Finch

  •  

    January 2008
    M T W T F S S
    « Oct   Mar »
     123456
    78910111213
    14151617181920
    21222324252627
    28293031  
  • My del.icio.us links

  • Flickr Photos

    S5001187

    S5001169

    S5001136

    More Photos
  • Wordpress Stuff

Archive for January, 2008

Classic ASP code to print current server name

Posted by pcfinch on January 29, 2008

Some simple ASP classic (VB script) code to print out the current server name. Unlike using the Request.ServerVariables(“SERVER_NAME”) function, this method returns the server that the ASP code actually ran on instead of the hostname passes in the URL. This is useful if there is number of backend servers running through a load balancer with “session affinity” and you what to know which one you are talking to.

<html>
<body>
<%
dim dos, env
set shell= CreateObject ("WScript.Shell")
set enviro = shell.Environment ("PROCESS")
whoami = " " & enviro("COMPUTERNAME")
response.write "Current server " & whoami
%>
</body>
</html>

Posted in VBScript | 2 Comments »