Обсуждение: problems compiling scripts.I'm near suicide

Поиск
Список
Период
Сортировка

problems compiling scripts.I'm near suicide

От
Ximo Domenech
Дата:
Hi.
I have been compiling scripts for two days, and cannot resolve the
problem with postgres. (working with solaris 2.7)
I don't know if the problem is in the compilation because it isn't
causes errors.
I am compiling with:

gcc  x.c y.c z.c -o xyzcgi -L/usr/local/pgsql/lib -R/usr/local/pgsql/lib
-lpq
mv xyzcgi /export/home/httpd/cgi-bin/pruebacgi

When the script is executed from a html page, returned this error to the
navigator:

Premature end of script headers: /export/home/httpd/cgi-bin/xyzcgi

In the log file of Apache I can see the same message and other:

Internal Server Error
Premature end of script headers: /export/home/httpd/cgi-bin/pruebacgi

Connection to database 'xyz' OK
DECLARE CURSOR command failed
[error] [client 127.0.0.1] Premature end of script headers


Can anyone help me ? Pleeeeeease.
I dont know how to continue. :-|

Thanks to everyone.

Re: [GENERAL] problems compiling scripts.I'm near suicide

От
Thomas Reinke
Дата:

Ximo Domenech wrote:

>
> Premature end of script headers: /export/home/httpd/cgi-bin/xyzcgi
>
> In the log file of Apache I can see the same message and other:
>
> Internal Server Error
> Premature end of script headers: /export/home/httpd/cgi-bin/pruebacgi
>
> Connection to database 'xyz' OK
> DECLARE CURSOR command failed

If you are really seeing the above in the log file, it would
indicate that
   1) You may have an error in the DECLARE statement causing it
      to fail.
   2) Most importantly, it looks like you are generating non http
      output (i.e. the "Connection to database 'xyz' OK).
      A typical header might read
          Content-type: text/html<CR>
          <Cr>
          <HTML> - and rest of html.

As a test, I would start by try running a simple script from
a command line and verifying that the output has the proper
HTTP header on it followed by HTML.

Below is an example of a script that displays the environment
passed to the CGI task on a browser screen (I usually call
this thing "env.sh". Start from something simple like this
and work your way up.

#!/bin/sh
echo "Content-type: text/html"
echo ""
echo "<HTML>"
echo "<BODY>"
echo "<PRE>"
env
echo "</PRE>"
echo "</BODY>"
echo "</HTML>"


> [error] [client 127.0.0.1] Premature end of script headers
>
> Can anyone help me ? Pleeeeeease.
> I dont know how to continue. :-|
>
> Thanks to everyone.

--
------------------------------------------------------------
Thomas Reinke                            Tel: (416) 460-7021
Director of Technology                   Fax: (416) 598-2319
E-Soft Inc.                         http://www.e-softinc.com

Re: [GENERAL] problems compiling scripts.I'm near suicide

От
Artur Pietruk
Дата:
On Tue, Aug 03, 1999 at 06:57:29PM -0100, Ximo Domenech wrote:
> Premature end of script headers: /export/home/httpd/cgi-bin/xyzcgi
>
> In the log file of Apache I can see the same message and other:
>
> Internal Server Error
> Premature end of script headers: /export/home/httpd/cgi-bin/pruebacgi
>
> Connection to database 'xyz' OK
> DECLARE CURSOR command failed
> [error] [client 127.0.0.1] Premature end of script headers

    It means that there is something wrong near "declare cursor" in
your source code. First of all check syntax of delcare cursor. If
everything is OK you should check permissions for all tables etc. inside
"declare cursor", if they are accessible to account 'nobody' (assuming
that your web-serwer is runnig as a nobody user). You should have postgres
account nobody (create it by shell-command 'createuser nobody') and
permisions (run psql your_database_name and than enter e.g.:
'grant all on your_table_name to nobody' ). You should also check
pg_hba.conf.

    Good luck!

--- Artur Pietruk, arturp@pdi.net

Re: [GENERAL] problems compiling scripts.I'm near suicide

От
Herouth Maoz
Дата:
At 22:57 +0300 on 03/08/1999, Ximo Domenech wrote:


> Internal Server Error
> Premature end of script headers: /export/home/httpd/cgi-bin/pruebacgi
>
> Connection to database 'xyz' OK
> DECLARE CURSOR command failed
> [error] [client 127.0.0.1] Premature end of script headers

I would say to check two things first:

1) That your first two lines of output are "Content-type: text/html" in
   the first line, followed by an empty line. If at all possible,
   output these two lines before even opening the database connection.

2) That your DECLARE CURSOR command is within a transaction block.

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma