See more articles about "perl "

Tutorial Addendum on Perl - Allotment B - Accepted Aperture Interface (CGI)



 31 December 18:00   

    



    



    

This affiliate describes:

    



        

  • What is Accepted Aperture Interface (CGI).

        



  •     

  • CGI ambiance variables provided by IIS.

        



  •     

  • Query string.

        



  •     

  • CGI appliance example, Calculator.pl.

        



  •     



    



    



    

What Is Accepted Aperture Interface (CGI)

    



    

Common Aperture Interface (CGI) is a agreement defines how a Web server program

    

interacts with appliance programs. The interactions are illustrated in the

    

following diagram:

    



    

Web Web CGI Appl.

    

Browser Internet Server Agreement Program

    



    

 

    

HTTP Env. Var.

    

appeal stdin

    

Send --------------> Catechumen ----------> Process

    

|

    

HTTP |

    

acknowledgment stdout V

    

Receive <----------- Catechumen <---------- Process

    



    



    

There are several basal rules with CGI:

    



        

  • Web server provides alotof of the ascribe advice

        

    to appliance programs through ambiance variables.

        



  •     

  • Data forward in the HTTP appeal with the GET adjustment is adapted to

        

    a appropriate ambiance variable, QUERY_STRING.

        



  •     

  • Data forward in the HTTP appeal with the Column adjustment is adapted to

        

    the accepted ascribe (stdin) channel.

        



  •     

  • Data printed to the accepted achievement (stdout) approach is converted

        

    to the HTTP response.

        



  •     



    



    



    

IIS Ambiance Variables

    



    

To understand how some ambiance variables are provided by the Web server, and

    

what advice they are containing, I wrote the chase Perl CGI program,

    

CgiEnv.pl.

    

 

    

#- CgiEnv.pl

    

#- Absorb (c) 1996 by Dr. Yang

    

#

    

book "Content-Type: text/html

";

    

book "<html><body>
";

    

foreach $var (sort keys(%ENV)) {

    

print($var, = , $ENV{$var}, "<br/>
");

    

}

    

book "</html></body>
";

    



    



    

Running it anon in a command window, I got:

    

 

    

Content-Type: text/html

    

<html><body>

    

ALLUSERSPROFILE = C:Documents and SettingsAll Users.WINNT<br/>

    

APPDATA = C:Documents and Settings\Application Data<br/>

    

COMMONPROGRAMFILES = C:Program FilesCommon Files<br/>

    

COMPUTERNAME = localhost<br/>

    

COMSPEC = C:WINNTsystem32cmd.exe<br/>

    

HOMEDRIVE = C:<br/>

    

HOMEPATH = Documents and Settings<br/>

    

LOGONSERVER = \localhost<br/>

    

NUMBER_OF_PROCESSORS = 1<br/>

    

OS = Windows_NT<br/>

    

OS2LIBPATH = C:WINNTsystem32os2dll;<br/>

    

PATH = D:Perlin;C:WINNTsystem32;C:WINNT;...

    

PATHEXT = .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH<br/>

    

PROCESSOR_ARCHITECTURE = x86<br/>

    

PROCESSOR_IDENTIFIER = x86 Ancestors 6 Archetypal 8 Dispatch 1, GenuineIntel...

    

PROCESSOR_LEVEL = 6<br/>

    

PROCESSOR_REVISION = 0801<br/>

    

PROGRAMFILES = C:Program Files<br/>

    

PROMPT = $P$G<br/>

    

SESSIONNAME = Console<br/>

    

SYSTEMDRIVE = C:<br/>

    

SYSTEMROOT = C:WINNT<br/>

    

TEMP = C:DOCUME~1\LOCALS~1Temp<br/>

    

TMP = C:DOCUME~1\LOCALS~1Temp<br/>

    

USERDOMAIN = home<br/>

    

USERNAME = <br/>

    

USERPROFILE = C:Documents and Settings<br/>

    

WINDIR = C:WINNT<br/>

    

</html></body>

    



    



    

Running it through IIS as a CGI application, I got:

    

 

    

ALLUSERSPROFILE = C:Documents and SettingsAll Users.WINNT

    

COMMONPROGRAMFILES = C:Program FilesCommon Files

    

COMPUTERNAME = localhost

    

COMSPEC = C:WINNTsystem32cmd.exe

    

CONTENT_LENGTH = 0

    

GATEWAY_INTERFACE = CGI/1.1

    

HTTPS = off

    

HTTP_ACCEPT = */*

    

HTTP_ACCEPT_LANGUAGE = en-us

    

HTTP_CONNECTION = Keep-Alive

    

HTTP_HOST = localhost

    

HTTP_USER_AGENT = Mozilla/4.0 (compatible; MSIE 6.0; MSNIA; Windows...

    

INSTANCE_ID = 1

    

LOCAL_ADDR = 127.0.0.1

    

NUMBER_OF_PROCESSORS = 1

    

OS = Windows_NT

    

OS2LIBPATH = C:WINNTsystem32os2dll;

    

PATH = D:Perlin;C:WINNTsystem32;C:WINNT;...

    

PATHEXT = .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH

    

PATH_INFO = /cgi-bin/CgiEnv.pl

    

PATH_TRANSLATED = c:inetpubwwwrootcgi-binCgiEnv.pl

    

PROCESSOR_ARCHITECTURE = x86

    

PROCESSOR_IDENTIFIER = x86 Ancestors 6 Archetypal 8 Dispatch 1, GenuineIntel

    

PROCESSOR_LEVEL = 6

    

PROCESSOR_REVISION = 0801

    

PROGRAMFILES = C:Program Files

    

REMOTE_ADDR = 127.0.0.1

    

REMOTE_HOST = 127.0.0.1

    

REQUEST_METHOD = GET

    

SCRIPT_NAME = /cgi-bin/CgiEnv.pl

    

SERVER_NAME = localhost

    

SERVER_PORT = 80

    

SERVER_PORT_SECURE = 0

    

SERVER_PROTOCOL = HTTP/1.0

    

SERVER_SOFTWARE = Microsoft-IIS/5.0

    

SYSTEMDRIVE = C:

    

SYSTEMROOT = C:WINNT

    

TEMP = C:WINNTTEMP

    

TMP = C:WINNTTEMP

    

USERPROFILE = C:Documents and SettingsDefault User.WINNT

    

WINDIR = C:WINNT

    



    



    

As you can see from the output, IIS has added some and removed some

    

environment variables in the CGI environment.

    



    



 


 environment, documents, interface, gateway, common, print, processor, cgienv, program, server, application, variables, windows, protocol, request, method, , documents and, interface cgi, gateway interface, common gateway, html <, environment variables, < body, web server, < html, common gateway interface, content type text, http request with,

Share Tutorial Addendum on Perl - Allotment B - Accepted Aperture Interface (CGI):
Digg it!   Google Bookmarks   Del.icio.us   Yahoo! MyWeb   Furl  Binklist   Reddit!   Stumble Upon   Technorati   Windows Live   Bookmark

Text link code :
Hyper link code:

Also see ...

Tutorial Addendum on Perl - Allotment B - Accepted Aperture Interface (CGI)
CGI Concern StringQuery String: The actual allotment of the requesting URL cord immediately afterwards the "?". Concern strings are usually acclimated to canyon a listo

Tutorial Addendum on Perl - Allotment B - Active Perl Programs with IIS
This affiliate describes:How to configure IIS 5.0 to run Perl programs.How to use perlis.dll instead of perl.exe with IIS.Performance allegory apartof Perl, JSP, and

Tutorial Addendum on Perl - Allotment B - Active Perl Programs with IIS
perl.exe vs. perlis.dllInstead of using perl.exe, you could aswell use perlis.dll to run your Perl programsthrough IIS. perlis.dll is the DLL of Perl for ISAPI.The advantage of using

Tutorial Addendum on Perl - Allotment B - RPC::XML Bore
Installing NMake 1.5Based on the documation, the accession action of RPC::XML bore requires the "make" utility. Since I am using a Windows arrangement now, so I charge to download a "make" account for Wi

Tutorial Addendum on Perl - Allotment B - RPC::XML Bore
RpcXmlServer2.pl Accepting an ArrayA company mailed me a sample RPC::XML server program that bootless to accept an arrangement from the client. The couldcause of the problem was accompanying to how an

Tutorial Addendum on Perl - Allotment B - SOAP::Lite Modules
This affiliate describes:Quick addition to SOAP. Overview of SOAP::Lite modules. Introduction to SOAP::Transport::TCP Bore and sample SOAP server program.

Tutorial Addendum on Perl - Allotment B - SOAP::Lite Modules
SOAP::Transport::TCP ModuleLet s attending at one of the SOAP server API bore first. SOAP::Transport::TCP has sub bore alleged SOAP::Transport::TCP::Server. It offers two functionalites:br

Tutorial Addendum on Perl - Allotment B - SOAP::Lite Modules
SOAP::Lite Archetype In the sample programs apparent in the antecedent section, you don t see any SOAP XML messages.And you don t see how the server and the applicant forward letters

Tutorial Addendum on Perl - Allotment B - Atrium Advice
This affiliate explains:What is a socket.How to authorize a atrium communication.A simple archetype of atrium server application.A simple arche

Tutorial Addendum on Perl - Allotment B - Atrium Advice
listen() Sets a atrium handle to accept approach with the defined chain admeasurement of incoming affiliation requests. This action is alone acclimated by the server application.For example: $queue