CGI Python problem

Tim Chase python.list at tim.thechases.com
Thu Nov 6 13:52:05 EST 2008


> Here is the permissions, which I think are definitely right now:
> 
> drwxrwxrwx   8 **** **** 4.0K Nov  6 13:34 public_html/
> 
> drwxrwxrwx   2 **** **** 4.0K Nov  6 13:35 cgi-bin/ [inside public_html]
> 
> -rw-r-xr-x  1 **** ****  117 Nov  6 11:39 test_pl.cgi* [inside cgi-bin]
> -rw-r-xr-x  1 **** ****  168 Nov  6 13:35 test_py.cgi* [inside cgi-bin]

Those indeed look kosher

> note both have *.cgi extensions otherwise plain text is shown.

I prefer to use .py (or .pl) for the extensions so my editors 
pick up the syntax...In my server's CGI directory, as long as the 
+x bits are set, it runs them with the .py extension.  However, 
that's an aesthetic matter.

> Also I think I should be getting a traceback since I used import
> cgitb; cgitb.enable() I wonder does this suggest the python
> interpreter hasn't be found?

It's certainly something to check...Apache may run in a chroot'ed 
environment where Perl may be available, and Python may not (or 
it may be someplace else in the chroot environment).

If you've got Perl hacking skills, you might throw together a 
simple perl-script that checks to see if /usr/bin/python exists 
where you think it is, or walks the directory tree returning the 
path of files containing the word "python". My perl skills are 
close to non-existent (only having reverse-engineered some 
hand-me-down perl code)

> Also I'm not sure how to check if the server is running mod_perl?

I think that's usually (assuming your admin hasn't munged them) 
included in the headers returned from the server, or if you've 
got PHP installed in the same setup, you can create a simple PHP 
page to dump the info (with this one line in it):

   <?php phpinfo();?>

which should include a line for the modules loaded in Apache.

Hope this gives you a few more things to check,

-tkc







More information about the Python-list mailing list