Setting up Python for CGI
Lee Braiden
lee_b at digitalunleashed.com
Fri Jul 15 08:38:55 UTC 2005
On Friday 15 July 2005 05:12, Gregory PiƱero wrote:
> Ok, I'm doing better, I think the server is _trying_ to execute my script!
> Other info:
> -My apache log file says "Premature end of script"
> -When I run the script from the console it works fine.
> -/usr/bin/python is where my python is.
> -Here are the permissions on the file:
> $ ls -l test.py
> -rwxr-xr-x 1 root root 646 2005-07-12 18:57 test.py
>
> #!usr/bin/python
>
> import sys
> import cgi
> import cgitb
> import MySQLdb
>
> cgitb.enable()
>
> sys.stderr=sys.stdout
try changing this section to:
---------------------------------------
#!/usr/bin/env python
import cgitb; cgitb.enable()
import sys
sys.stderr = sys.stdout
import cgi
import MySQLdb
---------------------------------------
That should make it more robust (by being independant of the web server's
paths etc.), and give it a better chance of sending errors to the browser.
--
Lee Braiden
http://www.DigitalUnleashed.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20050715/368f1e9a/attachment.sig>
More information about the ubuntu-users
mailing list