Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > [CGI] Basic newbie error or server configuration error?

Reply
Thread Tools

[CGI] Basic newbie error or server configuration error?

 
 
Gilles
Guest
Posts: n/a
 
      08-20-2012
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.
 
Reply With Quote
 
 
 
 
Gilles
Guest
Posts: n/a
 
      08-20-2012
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.
 
Reply With Quote
 
 
 
 
Rod Person
Guest
Posts: n/a
 
      08-20-2012
On Mon, 20 Aug 2012 13:41:20 +0200
Gilles <> 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


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


 
Reply With Quote
 
Gilles
Guest
Posts: n/a
 
      08-20-2012
On Mon, 20 Aug 2012 07:59:39 -0400, Rod Person
<> 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.
 
Reply With Quote
 
Hans Mulder
Guest
Posts: n/a
 
      08-20-2012
On 20/08/12 15:50:43, Gilles wrote:
> On Mon, 20 Aug 2012 07:59:39 -0400, Rod Person
> <> 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
 
Reply With Quote
 
Gilles
Guest
Posts: n/a
 
      08-20-2012
On Mon, 20 Aug 2012 16:56:14 +0200, Hans Mulder <>
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Caught Exception: System.Configuration.ConfigurationErrorsException: An error occurred loading a configuration file: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicK Mike ASP .Net 5 08-15-2007 08:57 AM
Enterprise Library exception: The configuration section securityCryptographyConfiguration is not defined in the current configuration for the AppDomain. Jess Chadwick ASP .Net 1 09-21-2006 09:18 AM
Configuration reverted to previous configuration after power loss ward@sciinc.com Cisco 0 03-03-2006 04:14 PM
Microsoft Configuration Block and Enterprise library configuration tool Mark ASP .Net 0 02-15-2006 11:27 PM
PEAP Configuration Woes - PEAP configuration help jester Cisco 1 12-20-2005 02:04 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57