Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

[CGI] Basic newbie error or server configuration error?

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


nospam at nospam

Aug 20, 2012, 4:41 AM

Post #1 of 6 (330 views)
Permalink
[CGI] Basic newbie error or server configuration error?

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.
--
http://mail.python.org/mailman/listinfo/python-list


nospam at nospam

Aug 20, 2012, 4:56 AM

Post #2 of 6 (321 views)
Permalink
Re: [CGI] Basic newbie error or server configuration error? [In reply to]

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.
--
http://mail.python.org/mailman/listinfo/python-list


rodperson at rodperson

Aug 20, 2012, 4:59 AM

Post #3 of 6 (325 views)
Permalink
Re: [CGI] Basic newbie error or server configuration error? [In reply to]

On Mon, 20 Aug 2012 13:41:20 +0200
Gilles <nospam [at] nospam> 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 [at] rodperson


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


--
http://mail.python.org/mailman/listinfo/python-list


nospam at nospam

Aug 20, 2012, 6:50 AM

Post #4 of 6 (317 views)
Permalink
Re: [CGI] Basic newbie error or server configuration error? [In reply to]

On Mon, 20 Aug 2012 07:59:39 -0400, Rod Person
<rodperson [at] rodperson> 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.
--
http://mail.python.org/mailman/listinfo/python-list


hansmu at xs4all

Aug 20, 2012, 7:56 AM

Post #5 of 6 (317 views)
Permalink
Re: [CGI] Basic newbie error or server configuration error? [In reply to]

On 20/08/12 15:50:43, Gilles wrote:
> On Mon, 20 Aug 2012 07:59:39 -0400, Rod Person
> <rodperson [at] rodperson> 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
--
http://mail.python.org/mailman/listinfo/python-list


nospam at nospam

Aug 20, 2012, 8:51 AM

Post #6 of 6 (318 views)
Permalink
Re: [CGI] Basic newbie error or server configuration error? [In reply to]

On Mon, 20 Aug 2012 16:56:14 +0200, Hans Mulder <hansmu [at] xs4all>
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.
--
http://mail.python.org/mailman/listinfo/python-list

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.