a script running a script

Jeff Jungblut jeff at soapzone.com
Fri Nov 2 16:08:42 CST 2001


~sdpm~
on 11/2/01 12:12 PM, Chuck Phillips at chuckphillips at mac.com wrote:

> I have a CGI script for the administration of a website that, when
> clicked, does a ton of stuff in the background for a ton of users. The
> problem is that now that after a certain number of users were added the
> script takes so long to finish what it's doing that the admin user's
> browser times out.

I used to have this problem; I don't believe it's the browser timing out but
the server timing out waiting for output from the CGI script and closing the
connection. Try making the script a non-parsed-header script that
continually flushes its output. Add "nph-" to the beginning of the script
name and set $| = 1 at the beginning of the script. In nph- scripts, you'll
need to send additional headers that the server normally generates for you.
Here's the function I use.

sub OutputHTTPHeader {
    if (!($httpHeaderSent)) {    # don't send it more than once

        if (($ENV{'SCRIPT_NAME'} =~ /nph-/ )) {
            $rightNow = &GetDateGMT(time,' ');
            $headerToSend .= "HTTP/1.1 200 OK\n";
            $headerToSend .= "Date: $rightNow\n";
            $headerToSend .= "Server: $ENV{'SERVER_SOFTWARE'}\n";
            $headerToSend .= "Connection: close\n";
        }

        if ($sendCookie) {
            &SetCookie;
        }

        $headerToSend .= "Content-Type: text/html\n\n";
        print "$headerToSend";
        $httpHeaderSent = 1;
    }
}

-- 
Jeff Jungblut
jeff at soapzone.com
http://soapzone.com/

~sdpm~

The posting address is: san-diego-pm-list at hfb.pm.org

List requests should be sent to: majordomo at hfb.pm.org

If you ever want to remove yourself from this mailing list,
you can send mail to <majordomo at happyfunball.pm.org> with the following
command in the body of your email message:

    unsubscribe san-diego-pm-list

If you ever need to get in contact with the owner of the list,
(if you have trouble unsubscribing, or have questions about the
list itself) send email to <owner-san-diego-pm-list at happyfunball.pm.org> .
This is the general rule for most mailing lists when you need
to contact a human.




More information about the San-Diego-pm mailing list