[Pythonmac-SIG] newbie

Kevin Altis altis at semi-retired.com
Thu Mar 11 14:04:06 EST 2004


Personally, I prefer the more technically correct (and explicit)  \r\n 
line endings for web headers. In the case of this example text/plain is 
more appropriate than html as the content-type.

print "Content-type: text/plain\r\n\r\n",

Besides the excellent suggestions in Philip's email you should also 
watch out for the line endings you use in your CGI scripts. If you are 
editing in Emacs, vi, etc. from the Terminal chances are you have 
newline (\n) line endings, but if you're editing with a text editor 
from the Finder you might be surprised to find your scripts ending with 
\r (carriage return) and if you brought a script over from a Windows 
box you could have \r\n line endings. If you're using Python 2.3.x I 
would think that the universal line-endings handling would work with 
all three versions on the Mac, but there might be problems with older 
versions.

ka
 

On Mar 11, 2004, at 10:21 AM, Bob Ippolito wrote:

> The script is not your problem at this point.  Check to make sure that 
> your apache configuration is correct, and the script is executable by 
> the user that runs apache.
>
> -bob
>
> On Mar 11, 2004, at 7:07 PM, salamander wrote:
>
>> like this?
>>
>> #!/usr/bin/python
>>
>> print "Content-type: text/html"
>> print
>>
>> for x in range(1,6):
>>   print x, x*x
>>
>> still bombs :(
>>
>> [Thu Mar 11 13:06:19 2004] [error] (2)No such file or directory: exec 
>> of /www/test/pyvqs/squares.py failed
>> [Thu Mar 11 13:06:19 2004] [error] [client 127.0.0.1] Premature end 
>> of script headers: /www/test/pyvqs/squares.py
>>
>>
>> On Mar 11, 2004, at 12:39 PM, Bob Ippolito wrote:
>>
>>>
>>> On Mar 11, 2004, at 6:29 PM, salamander wrote:
>>>
>>>> trying to execute the "squares.py" script from VQS's Python book, 
>>>> as a CGI:
>>> ---
>>>> but I get an Internal Server Error 500 in apache, and the error_log 
>>>> shows:
>>>>
>>>> [Thu Mar 11 12:10:47 2004] [error] (2)No such file or directory: 
>>>> exec of /www/test/pyvqs/squares.py failed
>>>> [Thu Mar 11 12:10:47 2004] [error] [client 127.0.0.1] Premature end 
>>>> of script headers: /www/test/pyvqs/squares.py
>>>
>>> It's broken because your script is not a CGI.  All CGIs, regardless 
>>> of language, must output valid HTTP headers.  Add this to the top of 
>>> your script:
>>>
>>> print "Content-type: text/html"
>>> print
>>>
>>> -bob
>>>
>>>
>>>
>>
>>
>> _______________________________________________
>> Pythonmac-SIG maillist  -  Pythonmac-SIG at python.org
>> http://mail.python.org/mailman/listinfo/pythonmac-sig
>
>
> _______________________________________________
> Pythonmac-SIG maillist  -  Pythonmac-SIG at python.org
> http://mail.python.org/mailman/listinfo/pythonmac-sig
>




More information about the Pythonmac-SIG mailing list