Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #27480 > unrolled thread

[CGI] Basic newbie error or server configuration error?

Started byGilles <nospam@nospam.com>
First post2012-08-20 13:41 +0200
Last post2012-08-20 17:51 +0200
Articles 6 — 3 participants

Back to article view | Back to comp.lang.python


Contents

  [CGI] Basic newbie error or server configuration error? Gilles <nospam@nospam.com> - 2012-08-20 13:41 +0200
    Re: [CGI] Basic newbie error or server configuration error? Gilles <nospam@nospam.com> - 2012-08-20 13:56 +0200
    Re: [CGI] Basic newbie error or server configuration error? Rod Person <rodperson@rodperson.com> - 2012-08-20 07:59 -0400
      Re: [CGI] Basic newbie error or server configuration error? Gilles <nospam@nospam.com> - 2012-08-20 15:50 +0200
        Re: [CGI] Basic newbie error or server configuration error? Hans Mulder <hansmu@xs4all.nl> - 2012-08-20 16:56 +0200
          Re: [CGI] Basic newbie error or server configuration error? Gilles <nospam@nospam.com> - 2012-08-20 17:51 +0200

#27480 — [CGI] Basic newbie error or server configuration error?

FromGilles <nospam@nospam.com>
Date2012-08-20 13:41 +0200
Subject[CGI] Basic newbie error or server configuration error?
Message-ID<6c84389rqmrj01cppc0ppiedqd44o4mfdf@4ax.com>
Hello

Apache fails running this basic CGI script that I found on the Net:

www.acme.com/cgi-bin/test.py?name=myname
===========
#!/usr/bin/env python

# Import modules for CGI handling
import cgi, cgitb

cgitb.enable()

# Create instance of FieldStorage
form = cgi.FieldStorage()

# Get data from field 'name'
#name = form['name'].value
name = form.getvalue('name')
===========

This is what I get:
===========
"Internal Server Error

The server encountered an internal error or misconfiguration and was
unable to complete your request.

Additionally, a 404 Not Found error was encountered while trying to
use an ErrorDocument to handle the request."
===========

FWIW, the script lives in www/cgi-bin/ where it should, was chmoded to
755, and I put the following .htaccess file:
===========
Options +ExecCGI
AddHandler cgi-script .py
===========

I'm not sure where to look for an error. Could it be some non-printed,
bad characters that prevent Python from compiling the source code?

Thanks for any help.

[toc] | [next] | [standalone]


#27481

FromGilles <nospam@nospam.com>
Date2012-08-20 13:56 +0200
Message-ID<8d9438d5f3j9ljtk5lphkvsvn3bundurnm@4ax.com>
In reply to#27480
Found it: The script MUST return something to the browser. I was
missing this:

========
print "Content-Type: text/html;charset=utf-8"
print

# print a document
print "Name is %s" % ( cgi.escape(name), )
========

Sorry about that.

[toc] | [prev] | [next] | [standalone]


#27483

FromRod Person <rodperson@rodperson.com>
Date2012-08-20 07:59 -0400
Message-ID<mailman.3549.1345464328.4697.python-list@python.org>
In reply to#27480
On Mon, 20 Aug 2012 13:41:20 +0200
Gilles <nospam@nospam.com> wrote:

> Hello
> 
> Apache fails running this basic CGI script that I found on the Net:
> 
> www.acme.com/cgi-bin/test.py?name=myname
> ===========
> #!/usr/bin/env python
> 
> # Import modules for CGI handling
> import cgi, cgitb
> 
> cgitb.enable()
> 
> # Create instance of FieldStorage
> form = cgi.FieldStorage()
> 
> # Get data from field 'name'
> #name = form['name'].value
> name = form.getvalue('name')
> ===========
> 
> This is what I get:
> ===========
> "Internal Server Error
> 
> The server encountered an internal error or misconfiguration and was
> unable to complete your request.
> 
> Additionally, a 404 Not Found error was encountered while trying to
> use an ErrorDocument to handle the request."
> ===========
> 
> FWIW, the script lives in www/cgi-bin/ where it should, was chmoded to
> 755, and I put the following .htaccess file:
> ===========
> Options +ExecCGI
> AddHandler cgi-script .py
> ===========
> 
> I'm not sure where to look for an error. Could it be some non-printed,
> bad characters that prevent Python from compiling the source code?
> 
> Thanks for any help.


Check the Apache error log, there should be more information there.

-- 

Rod Person  http://www.rodperson.com  rodperson@rodperson.com


Sent From Claws Mail 3.8.0cvs30 Win7 x86 GTK+ 2.16.6/GLib 2.24.0

[toc] | [prev] | [next] | [standalone]


#27493

FromGilles <nospam@nospam.com>
Date2012-08-20 15:50 +0200
Message-ID<d4g4385sgr2a4t0udhki4edn8vbsv3j55f@4ax.com>
In reply to#27483
On Mon, 20 Aug 2012 07:59:39 -0400, Rod Person
<rodperson@rodperson.com> wrote:
>Check the Apache error log, there should be more information there.

It's a shared account, so I only have access to what's in cPanel,
which didn't display anything. Problem solved.

Thank you.

[toc] | [prev] | [next] | [standalone]


#27499

FromHans Mulder <hansmu@xs4all.nl>
Date2012-08-20 16:56 +0200
Message-ID<5032500e$0$6925$e4fe514c@news2.news.xs4all.nl>
In reply to#27493
On 20/08/12 15:50:43, Gilles wrote:
> On Mon, 20 Aug 2012 07:59:39 -0400, Rod Person
> <rodperson@rodperson.com> wrote:
>> Check the Apache error log, there should be more information there.
> 
> It's a shared account, so I only have access to what's in cPanel,
> which didn't display anything.

Most such panels have a button to show the error log for your own site.

If you can't find it, ask the help desk of the web hosting company.

If there really is no way for you to see the error log, ask the help
desk to mail you the error message.

-- HansM

[toc] | [prev] | [next] | [standalone]


#27503

FromGilles <nospam@nospam.com>
Date2012-08-20 17:51 +0200
Message-ID<02n43856s6jcnkis3oempcftn1fiq67nnl@4ax.com>
In reply to#27499
On Mon, 20 Aug 2012 16:56:14 +0200, Hans Mulder <hansmu@xs4all.nl>
wrote:
>Most such panels have a button to show the error log for your own site.
>
>If you can't find it, ask the help desk of the web hosting company.
>
>If there really is no way for you to see the error log, ask the help
>desk to mail you the error message.

Thanks. the cPanel at my provider only has a Logs > Error Log icon,
but the error I was having didn't result in anything in the log file.

I'll set up a Linux host at home and test Python scripts before
uploading them to my ISP.

Thank you.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web