mkscgi

run scripts on HTTP server through Common Gateway Interface 

Command


SYNOPSIS

virtual path/mkscgi.exe/virtual path/file


DESCRIPTION

mkscgi provides a facility for running KornShell scripts on HTTP servers through the Common Gateway Interface (CGI). mkscgi also executes any binary and script when they have a registry association.

mkscgi parses content returned from an HTML form, and converts each field into a WWW_ environment variable. It then executes the binary associated with the script specified in extended path information of the HTML form statement. For example, for the form statement

<form method="POST" action="/cgi-bin/mkscgi.exe/cgi-bin/mkscalc.ksh">

mkscgi reads the content returned from the browser, parses each field into a WWW_ environment variable, then passes those environment variables through to the script. Additionally, all system environment variables are expanded and passed to the script.

In the above example, the directory name (cgi-bin) following mkscgi.exe is a virtual path defined by the server administrator. The server expands the virtual path into the environment variable PATH_TRANSLATED.

Use registry to make the registry association for a custom script extension and binary:

registry -s -k 'HKEY_CLASSES_ROOT\.ext' -n '' -v 'string_value'
registry -s -k 'HKEY_CLASSES_ROOT\string_value\Shell\Open\Command'
	   -n '' -v 'custom.exe %1'

For scripts with extensions .ksh and .sh, the shell specified in the SHELL environment variable is executed directly and not looked up in the registry.

mkscgi is not a command line utility. mkscgi uses system variables which are defined by HTTP servers and must therefore be launched by an HTTP server.


EXAMPLE INSTALLATION

Several example HTML and script files are included with PTC MKS Toolkit. If they were not installed during setup and are not located in $ROOTDIR/mksnt/www, then run PTC MKS Toolkit setup.exe. At the Setup Type window choose Custom to install the Internet Server Support files.

Basic installation of the example scripts assumes that your HTTP server is configured to have a dedicated CGI directory and that PTC MKS Toolkit is installed.

No changes or additions are required to browser mime types or to the registry. First put the files into the right directories and then write your own .htm and .ksh scripts.


ENVIRONMENT VARIABLES

WWW_fieldname 

Browser form content is parsed by mkscgi and placed into the environment. Each form field name is prefixed with WWW_. If a field name begins with an underbar, one underbar is removed. Dots in a field name are converted to underbars.

REQUEST_METHOD 

User defined in .html file. Must be defined as POST or GET.

QUERY_STRING 

Contains form content if REQUEST_METHOD is GET. If REQUEST_METHOD is POST it can contain the URL-embedded constant information. mkscgi does not process this embedded information.

CONTENT_LENGTH 

Set by your web server.

PATH_TRANSLATED 

Full path name of the specified script. The form statement extra path information contains a virtual path which is expanded by the server.

SHELL 

Full path name of sh.exe.

ROOTDIR 

Full path name of MKS Toolkit's root directory.


DIAGNOSTICS

Possible exit status values are:

0 

Successful completion.

1 

Failure due to any of the following:

— environment variable [variable] normally set by HTTP server not correctly set
— form method must be POST or GET
— your browser didn't send any content
— could not allocate memory
— cannot determine script to run because PATH_TRANSLATED is not set
— failed to run shell
— insufficient memory
— error finding script extension in registry
— error reading script extension value from registry
— error finding binary association in registry
— error reading binary association from registry
— form data is corrupt
— invalid escape sequence in value
— unable to read system environment variables from registry
— error expanding registry system environment variables
— system environment variable too long

mkscgi attempts to send any error messages back to the client browser.


PORTABILITY

Windows 8.1. Windows Server 2012 R2. Windows 10. Windows Server 2016. Windows Server 2019. Windows 11. Windows Server 2022. mkscgi has been tested using Netscape FastTrack Server 2.0 and Microsoft Information Server 3.0.


AVAILABILITY

PTC MKS Toolkit for System Administrators
PTC MKS Toolkit for Developers
PTC MKS Toolkit for Interoperability
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


PTC MKS Toolkit 10.4 Documentation Build 39.