• Welcome to OS2World OLD-STATIC-BACKUP Forum.
 

News:

This is an old OS2World backup forum for reference only. IT IS READ ONLY!!!

If you need help with OS/2 - eComStation visit http://www.os2world.com/forum

Main Menu

Environment variables

Started by jep, 2008.04.24, 15:34:20

Previous topic - Next topic

jep

Marked as: Easy
Hello,

If you'd like to write some rexx script that you want others to use than you may need to determine where to install your script (by default or suggest user) but also so gather info to make the script work properly.

There are a number of varibles set in config.sys that can help you out, e.g. the temp folder and default installation path for programs. The user may set them during system installation or change them later on to something else so you should therefore never hard code them into your scripts.

If you look in config.sys you'll notice a number of lines that begin with the word SET followed by another word and an equal sign. The word between SET and = is the variable that hold the text/value after the equal sign and that's the name you should use to retrieve the information and possibly change/manipulate.

Note that you can't find some of these params in OS/2 as they've been introduced in eComStation. You may have to dig a bit deeper to find out the same info. if you want to support Warp 3 and 4.

You can also temporarily set params that will be vaild for the session/script that run to use e.g. more resources, allow paths to be searched for dlls etc. (modify PATH).

/* Useful info about system */

say 'Operating System: 'value( 'OS',, 'ENVIRONMENT' )
say 'Operating System installation directory: 'value( 'OSDIR',, 'ENVIRONMENT' )
say 'Host name: 'value( 'HOSTNAME',, 'ENVIRONMENT' )
say 'Time Zone: 'value( 'TZ',, 'ENVIRONMENT' )
say 'Country & Language: 'value( 'LANG',, 'ENVIRONMENT' )
temp = value( 'TEMP',, 'ENVIRONMENT' )
if length( strip( temp ) ) = 0 then
   temp = value( 'TMP',, 'ENVIRONMENT' )
say 'Temp directory: 'temp
say 'Install programs to 'value( 'PROGRAMS',, 'ENVIRONMENT' )
say 'Place settings for applications in: 'value( 'HOME',, 'ENVIRONMENT' )

RobertM

#1
And... if you are writing a cgi script for a web server, the format is very much the same - the CGI var names are primarily what is different.

Here's a snippet of code I use to retrieve a few CGI vars:

    env = 'OS2ENVIRONMENT'

    HTTP_HOST       =Value("HTTP_HOST",,env)
    REFERER_URL     =Value("REFERER_URL",,env)
    HTTP_REFERER    =Value("HTTP_REFERER",,env)


The list of CGI vars I use is:

GATEWAY_INTERFACE
SERVER_PORT     
SERVER_PROTOCOL 
SERVER_ROOT     
SERVER_NAME     
SERVER_ADDR     
HTTP_HOST       

REFERER_URL      (these two are the same - the client or server will interpret/send only one)
HTTP_REFERER     

HTTP_CONNECTION 
REQUEST_METHOD   
QUERY_STRING     
PATH_INFO       
SCRIPT_NAME     
DOCUMENT_ROOT   
HTTP_ACCEPT     
DOCUMENT_URI     
HTTP_USER_AGENT 
SERVER_SOFTWARE 

REMOTE_HOST      (these two are the same for IP only tracking)
REMOTE_ADDR     


There may be others used on different servers as well...

Robert


|
|
Kirk's 5 Year Mission Continues at:
Star Trek New Voyages
|
|