Skip to main content development
   toolset
 
  Easy400   |       iSeries home
Public-Source
 
Introduction
Tutorial
Examples
FAQ
Index
Download
 
 

 
2.7 - Environment variables


When the server runs a CGI program, it passes information about the request and about the server itself to the CGI program using environment variables.
Environment variables answer a number of questions that a CGI may raise, for instance:

  • what is the domain of this server?
  • what is my URI?
  • what is the query string?
  • what is the username that logged in? For more information about supported environment variables, please see Environment variables set by HTTP server in iSeries Infocenter.

    We also provide an ILE-COBOL environment variables sample program that displays a number of environment variables.

    Service program cgicbldev2/cgicbldev2 supports the following procedures related to environment variables:

    1.  QGetEnv  - Retrieve an environment variable
      Use this procedure to retrieve a given environment variable.
      Input parameter:
      • name of the desired environment variable (char 100)
      Returned value:
      • environment variable value (char 32767)

      Example:
                  ...         ...         ...
             SPECIAL-NAMES.
                   copy CPYSPCNAME of CGICBLDEV2-QCBLLESRC.
                  ...         ...         ...
            * Variables for QGetEnv procedure
                 05     envVarNam           PIC  X(100).
                 05     envVarVal           PIC  X(32767).
                  ...         ...         ...
            * Retrieve environment variable "SERVER_NAME"
                 move 'SERVER_NAME'       to envVarNam.
                 call 'QGETENV' using envVarNam
                                returning into envVarVal


    2.  QPutEnv  - Put an environment variable
      In some circumstances, one may need to change the value of an existing environment variable, or to create a new environment variable.
      This is useful for communication between programs running in the same job, such as a CGI and the Net.Data language environment.

      The following parameter must be passed:

      1. a string containing an expression (char 32767).
        See the example.

      Example:
                  ...         ...         ...
             SPECIAL-NAMES.
                   copy CPYSPCNAME of CGICBLDEV2-QCBLLESRC.
                  ...         ...         ...
            * Variables for QPutEnv procedure
                 05     envVarVal           PIC  X(32767).
                  ...         ...         ...
            * Set to blank environment variable QUERY_STRING
                 move 'QUERY_STRING='     to envVarVal.
                 call procedure 'QPUTENV' using envVarVal.
      





  •     Contact