[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [Way OT] perl, CGI, and sendmail



On Sun, 10 Apr 2005, David wrote:

> On Sun, Apr 10, 2005 at 11:25:48PM +0200, Almut Behrens wrote:
> > On Sun, Apr 10, 2005 at 03:39:08PM -0500, David wrote:
> > > I know this ain't Debian but I've racked my brain on this.
> > >
> > > Been experimenting with CGI, using perl.  I have a form that generates
> > > the needed variables, etc.
> > >
> > > I have it to where when I submit the data, the mail is sent and I
> > > receive it (FWIW, using exim4), Exim doesn't report any errors, but I
> > > get a 500 error (Internal Server Error) from apache (1.3.33-4).
> >
> > You're not generating any output to return to the browser (you know,
> > that typical pretty useless page "Your mail has been sent. Thank you
> > for ..." ;)
>
> No, that file I attached was the entire thing - it's just a learning
> project.
>
> > When a CGI script doesn't produce any output, it's
> > considered an "internal error" by the server.
>
> But I was getting output.  In the sendmail example I included, I
> received a perfect mail.  As I said in the OP, no errors showed up in
> the exim logs, but I'd get an "Internal Error" report in the web browser
> and the apache logs reported a 500 error.  IOW, it appears that perl
> processed the script all the way but was returning an error to apache
> for some reason.

No - the script executes just fine. The server returns the error because
it doesn't get any useful output. See below.

>
> If I edited the cgi.pl file by commentint out the sendmail stuff and
> added some html tags and sending to stdout (in the pl), I got the
> correct message in the browser and a 200 status in the logs.

But that's precisely the point - now the script has output --  the HTML
code. The point of CGI is that the CGI script returns HTML to the server,
which then sends it to the browser. If the script exits without sending
HTML to the server, the server reports an error (unless you've told it
explicitly not to expect the HTML). So the fact that the script produces
emailed output is irrelevant to the server - it's an error unless it
produces HTML output sent to STDOUT.

> It certainly isn't..  I was just hoping for a quick answer as to what's
> wrong with the script - I'm sure that it's something in the script.

But it's not - it's a fine script, just not CGI.


----------------------------------------------------------------------
Andrew J Perrin - http://www.unc.edu/~aperrin
Assistant Professor of Sociology, U of North Carolina, Chapel Hill
clists@perrin.socsci.unc.edu * andrew_perrin (at) unc.edu





Reply to: