MyWebServer
Home Free Downloads Docs FAQ's The Collective Community Tools Help About MyWebServer

MyWebServer |   Technical Info
 
 

Get Environment Variables Sample
The Get Environment Variables Sample CGI displays the phrase Hello World in a web browser window.

 

 What You See When you Run GetEnvironmentVariables.exe

GET ENVIRONMENT VARIABLES


QUERY_STRING

query


REMOTE_ADDR

10.27.55.152


Click Here to download this compiled CGI.

Running The Get Environment Variables Sample
The Get Environment Variables Sample can be run on the same computer as MyWebServer.  Just type the following URL into your web browser. http://localhost/cgi-bin/GetEnvironmentVariables.exe?query

 The C Version of Get Environment Variables
#include <stdio.h>
#include <malloc.h>
#include <string.h>
#include <stdlib.h>

int main(int argc, char* argv[])
{
        printf("Content-type: text/html\n\n");
        printf("<HTML>");
        printf("<HEAD>");
        printf("<TITLE>");
        printf("GET ENVIRONMENT VARIABLES PAGE");
        printf("</TITLE>");
        printf("</HEAD>");
        printf("<BODY>");
        printf("<H2>GET ENVIRONMENT VARIABLES</H2>");
        printf("<HR><P>");
        printf("QUERY_STRING </P><P>");
        printf(getenv("QUERY_STRING"));
        printf("</P><HR><P>");
        printf("REMOTE_ADDR </P><P>");
        printf(getenv("REMOTE_ADDR"));
        printf("</P><HR>");
        printf("</BODY>");
        printf("</HTML>");
        return 0;
}
        
Click Here to download this file.

 

 The PERL Version of Get Environment Variables
#!/usr/local/bin/perl

print ("Content-type: text/html\n\n");
print ("<HTML>");
print ("<HEAD>");
print ("<TITLE>");
print ("GET ENVIRONMENT VARIABLES PAGE");
print ("</TITLE>");
print ("</HEAD>");
print ("<BODY>");
print ("<H2>GET ENVIRONMENT VARIABLES</H2>");
print ("<HR><P>");
print ("QUERY_STRING </P><P>");
print ("$ENV{'QUERY_STRING'}");
print ("</P><HR><P>");
print ("REMOTE_ADDR </P><P>");
print ("$ENV{'REMOTE_ADDR'}");
print ("</P><HR>");
print ("</BODY>");
print ("</HTML>");

        
Click Here to download this file.
 
 

[ Home ] [ Downloads ] [ Docs ] [ FAQs ] [ The Collective ] [ Community ] [ Tools ] [ Help ] [ About ]