in reply to Re: Parse HTML content
in thread Parse HTML content

i am getting 500 internal server error. As this is a cgi script. The script goes fine in the terminal but as the html file is too large i have to see whats wrong with it as cgi page.

Replies are listed 'Best First'.
Re^3: Parse HTML content
by bitingduck (Deacon) on Mar 09, 2012 at 18:14 UTC

    Check your server logs to see what the error is-- it's likely a permissions problem, but depending on the server could also be a Perl version problem.

    For example, Mac OS X has multiple Perl installs and you can write something that works fine from the terminal, then the CGI handler uses a different version of Perl that doesn't have any of your modules installed. Particularly annoying, since OS X depends on having the version it wants, so you end up with 2 or 3 (or more) installs and having to sort between them.

    But it's most likely permissions, since the CGI will run as a different user than you run as in command line mode. There are other possibilities, as well, and your server's error log should give you a clue where to look

    EDIT: also, if you really think it's the size of the target HTML, an easy check would be to put a mini-version of the target page up (or something similar) that has just enough data for your CGI to act on. You could even do it as dummy data embedded in the Perl code itself-- that would let you test that possibility quickly. But look at the error logs first- it might tell you exactly what the problem is

Re^3: Parse HTML content
by Eliya (Vicar) on Mar 09, 2012 at 18:13 UTC

    The first step when getting an internal server error would typically be to check the error log of the webserver.

    The script goes fine in the terminal but as the html file is too large...

    How large is the HTML?  Maybe the webserver process is running under a memory limit lower than your terminal user?   (assuming you've verified that the CGI script runs in principle...)

      How can i check if the webserver process is running under a memory limit lower than my teminal user?

        Depends on a variety of factors...  On newer Linux boxes you could, for example, do

        print qx(cat /proc/self/limits);

        from within your CGI script.  (And then compare it with the contents of /proc/self/limits when queried from the terminal.)