Apache OS/2 CGI patch (was Re: Apache/2 web server)

Apache OS/2 CGI patch (was Re: Apache/2 web server)

Post by Kyler Lai » Fri, 10 Jan 1997 04:00:00



Quote:>> Yes!  The cgi module needs to be patched a bit, especially
>> to run Perl/shell scripts nicely.
>> If anyone here is interested in making the changes that I'm
>> describing, let me know and I'll post them here when I get
>> home.
>Yes please! I eagerly want this to get to work!

O.k...here is the change that I made to cgi_child() in
mod_cgi.c.  It's from an old mod_cgi.c, so it might have
changed significantly since my copy.

===================================
#ifdef __EMX__    
    if((!r->args) || (!r->args[0]) || (ind(r->args,'=') >= 0)) {
                int emxloop;
                char *emxtemp;

                /* For OS/2, place the variables in the current
            environment then it will be inherited. This way
            the program will also get all of OS/2's other SETs. */
                for (emxloop=0; ((emxtemp = env[emxloop]) != NULL); emxloop++)
                        putenv(emxtemp);

                /* Special case to allow use of REXX commands as scripts. */
                if (strstr(strupr(r->filename), ".CMD") > 0) {
                        os2pathname(r->filename);
                        execl("CMD.EXE", "CMD.EXE", "/C", r->filename, NULL);
                }

                /* Special case to allow execution of binaries. */
                else if (strstr(strupr(r->filename), ".EXE") > 0) {
                        execl(r->filename, argv0, NULL);
                }

                /* Give it to a shell to handle. */
                else {
                        execl("TCSH.EXE", "TCSH.EXE", "-c", r->filename, NULL);
                }
    } else {
===================================

The part I added is the line with "TCSH.EXE".  TCSH is
able to handle files such as

        #!/usr/local/bin/perl

        print "Hi!  I'm a Perl script!\n";

Of course, you could eliminate the call to the shell if
you added something like

                /* Special case to allow execution of binaries. */
                else if (strstr(strupr(r->filename), ".PL") > 0) {
                        execl("PERL.EXE", "PERL.EXE", r->filename, NULL);
                }

Since you should be using MultiViews anyway, you'll never
see the extension in the URL, so changing from one to
another shouldn't be a problem.

--kyler