Coming from Perl

Bryan Olson fakeaddress at nowhere.org
Sat Sep 15 01:32:31 EDT 2007


Amer Neely wrote:
> This seems to indicate that maybe my host needs to configure Apache to 
> run python scripts? But I didn't need to do anything with mine.

Another possibility: If it works on Windows but not Unix, check
the end-of-line characters. Windows ends each line with the two
character sequence carriage-return + newline, which in Python
is "\r\n". Unix uses newline alone, "\n".

Most Unixies will choke on a #! line with a carriage return.
The Python interpreter will accept source files with either
end-of-line on either system, but of course you'll not get
that far unless the operating system respects the shebang line.

Maybe you already checked that. Hmmm...other possiblities...

Do you have shell access? Can you executing it directly from
the shell? Do you get a Python error, or some other?

Did you:  chmod ugo+rx <yourscript>

Is Python in /usr/bin? What does "which python" say?

Generally, most experts seem to prefer:

     #!/usr/bin/env python

You might try changing the the extension of your script from .py
to .cgi. Windows uses the .py to choose the executable, but Unix
does not care; it used the shebang line.


-- 
--Bryan



More information about the Python-list mailing list