[PLUG] python as a cgi in Apache
Josh Orchard
josh at emediatedesigns.com
Fri Sep 13 06:05:21 UTC 2002
Since apache doesn't have a shell. /etc/passwd has /usr/false I can't su
to that user. I did change it and have apache run the script and it is
fine.
I have also tried to run this as my user. I can run the script at a
command prompt fine but apache can't.
I tried this again on windows and I do not have a problem. I'm thinking
that the version of python on the linux is causing the problem. That or
the version of Apache. That is the only difference. I have 1.3.22 apache
and 2.2.1 Python. on linux.
1.3.26 Apache and 2.1 and 2.2.1 python on windows.
Suggestions? Has anyone tried this?
As always thanks for any help.
Josh
> On Thursday 12 September 2002 10:59 am, Josh Orchard wrote:
>> That's ok. I have now tried the following:
>>
>> #!/usr/bin/python2
>> print "Content-Type: text/html\n\n"
>> print "hello"
>>
>>
>> and it still gives me the same error. Also I do have this working
>> fine on my windows apache and python. I would just want to move it to
>> my Linux server. I think everything is correct. I can run ./test.py
>> at the prompt and it runs fine. I just don't understand it all.
>> GGrrrr.
>> Thanks for the suggestions. Still need to find the way to just get a
>> simple cgi to execute.
>> Josh
>>
>> > Sorry about that....that didn't help much....
>> >
>> > a simple:
>> > print "Content-Type: text/html\n\n"
>> > should work fine...
>> >
>> > Brian Horan wrote:
>> >> There is an easier way....
>> >> http://www.python.org/doc/lib/node295.html
>> >>
>> >> Josh Orchard wrote:
>> >> > Try that also. the \n do present new line returns. That was one
>> >> > of the issues with the bug from Apache I read. Something about
>> >> > after the headers there needs to be a new line.
>> >> > The script runs fine from a command line. It returns output that
>> >> > looks fine.
>> >> >
>> >> > Josh
>> >> >
>> >> > > On Thu, 12 Sep 2002, Josh Orchard wrote:
>> >> > >> I then try to execute a simple python script:
>> >> > >> (~josh/cgi-bin/test.py) #!/usr/bin/python2
>> >> > >>
>> >> > >> print '''
>> >> > >> Content-Type: text/html\n\n
>> >> > >> <html>
>> >> > >> <head>
>> >> > >> <title>Hello there </title>
>> >> > >> </head>
>> >> > >>
>> >> > >> <body>
>> >> > >>
>> >> > >> Hello
>> >> > >> </body>
>> >> > >> </html>
>> >> > >> '''
>> >> > >>
>> >> > >>
>> >> > >> I get server 500 errors and the logs show:
>> >> > >>
>> >> > >> Premature end of script headers:
>> >> > >> /home/josh/public_html/cgi-bin/test.py
>> >> > >
>> >> > > I don't know much python, so I may be way off the mark -- but
>> >> > > my hunch is that your script is a literal '\n\n' string, not
>> >> > > two newlines, in your Content-Type description. Try this:
>> >> > >
>> >> > > print '''
>> >> > > Content-Type: text/html
>> >> > >
>> >> > > <html>
>> >> > > ...
>> >> > > </html>
>> >> > > '''
>> >> > >
>> >> > > --Paul Heinlein <heinlein at attbi.com>
>> >> > >
> Do you have permissions right?
> Can nobody or whoever you apache runs as execute the script?
>
> --
> Ken Stephens
> CAD2CAM.COM
> CADtoCAM.COM
>
> _______________________________________________
> PLUG mailing list
> PLUG at lists.pdxlinux.org
> http://lists.pdxlinux.org/mailman/listinfo/plug
More information about the PLUG
mailing list