Mailing List Archive

Difficulty configuring web server for Python
My situation: I just obtained a "virtual web server" account at a web
hosting place, where I have full access to UNIX on the box and can
modify my apache config files, etc. They advertise that they support
Perl, C, and C++ for CGI scripting. Needless to say, first thing I did
when I got the account was to build a copy of Python. Python appears to
work fine.

I built a simple CGI script and kept getting error 500, so I simplified
to the below script:

#!/usr/home/campusch/usr/local/bin/python


print "Content-type: text/html"
print
print "<HTML><BODY><H1>Hello World!</H1></BODY></HTML>"
print


1) Python is installed in /usr/home/..../python
2) running "python simp.py" from the command prompt gives me the
expected result.
3) running "./simp.py" from that directory runs the program just fine.
4) python itself has been chmod ugo+x so the web server process should
be able to run it.
5) This script has been chmod ugo+x so the web server process should be
able to run it.
6) The script is in the correct directory; I installed a "supported"
perl script in this directory and got it to work no problem.

This is what gets written to the server log when I try to run my script:

[Sun Aug 15 21:59:31 1999] [error] (2)No such file or directory: exec of
/usr/local/etc/httpd/cgi-bin/simp.py failed
[Sun Aug 15 21:59:31 1999] [error] Premature end of script headers:
/usr/local/etc/httpd/cgi-bin/simp.py

While the "no such file or directory" threw me, this is not a file not
found error... when I tried to run a script that really wasn't there, I
got:

[Sun Aug 15 22:10:18 1999] [error] script not found or unable to stat:
/usr/local/etc/httpd/cgi-bin/foo.py

I noticed in my srm.conf file that they had the line
AddType application/x-httpd-cgi .cgi

in there, so I renamed the .py file to .cgi. No help at all.

As for the OS I'm running, here's what python prints on the first line
when I run it:

Python 1.5.2 (#3, Aug 15 1999, 19:04:09) [GCC 2.7.2.1] on bsdos3

My first recourse (after spending 3 hours trying to chase this down) was
to contact tech support; they agreed with me that Python is a robust
scripting language, but in order to make sure that they have time to
handle all their clients' requests for supported software, they have had
to tighten their policy and they aren't allowed to even help me a teensy
bit when I'm using unsupported software.

Frustrating as heck. Anyway, if anyone here has any suggestions as what
to try next, I would appreciate it. I can't recompile apache but I can
change the config files. I can however run a script to find out the
version of Apache I'm using, and here it is:

Server version: Apache/1.3.1.1 SSL/1.15 PHP/3.0.3
Server built: Jun 3 1999 11:15:00
Standalone Configuration

I don't want to have to learn perl and I really don't want to do my
scripting in C++. So if anyone here has any suggestions, I'd greatly
appreciate it.

Thanks,
-Fred


--------
Michael "Fred" Fredericks
PhD Student, Computer Science
University of Maryland College Park
fred.at.cs.dot.umd.dot.edu ---- note I never check my dejanews mail.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
Difficulty configuring web server for Python [ In reply to ]
Do you think "home" has the same meaning for the server ?
#!/usr/home/campusch/usr/local/bin/python

--
--Darrell
<mbf2y@my-deja.com> wrote in message news:7p9855$5tg$1@nnrp1.deja.com...
> My situation: I just obtained a "virtual web server" account at a web
> hosting place, where I have full access to UNIX on the box and can
> modify my apache config files, etc. They advertise that they support
> Perl, C, and C++ for CGI scripting. Needless to say, first thing I did
> when I got the account was to build a copy of Python. Python appears to
> work fine.
>
> I built a simple CGI script and kept getting error 500, so I simplified
> to the below script:
>
> #!/usr/home/campusch/usr/local/bin/python
>
>
> print "Content-type: text/html"
> print
> print "<HTML><BODY><H1>Hello World!</H1></BODY></HTML>"
> print
>
>
> 1) Python is installed in /usr/home/..../python
> 2) running "python simp.py" from the command prompt gives me the
> expected result.
> 3) running "./simp.py" from that directory runs the program just fine.
> 4) python itself has been chmod ugo+x so the web server process should
> be able to run it.
> 5) This script has been chmod ugo+x so the web server process should be
> able to run it.
> 6) The script is in the correct directory; I installed a "supported"
> perl script in this directory and got it to work no problem.
>
> This is what gets written to the server log when I try to run my script:
>
> [Sun Aug 15 21:59:31 1999] [error] (2)No such file or directory: exec of
> /usr/local/etc/httpd/cgi-bin/simp.py failed
> [Sun Aug 15 21:59:31 1999] [error] Premature end of script headers:
> /usr/local/etc/httpd/cgi-bin/simp.py
>
> While the "no such file or directory" threw me, this is not a file not
> found error... when I tried to run a script that really wasn't there, I
> got:
>
> [Sun Aug 15 22:10:18 1999] [error] script not found or unable to stat:
> /usr/local/etc/httpd/cgi-bin/foo.py
>
> I noticed in my srm.conf file that they had the line
> AddType application/x-httpd-cgi .cgi
>
> in there, so I renamed the .py file to .cgi. No help at all.
>
> As for the OS I'm running, here's what python prints on the first line
> when I run it:
>
> Python 1.5.2 (#3, Aug 15 1999, 19:04:09) [GCC 2.7.2.1] on bsdos3
>
> My first recourse (after spending 3 hours trying to chase this down) was
> to contact tech support; they agreed with me that Python is a robust
> scripting language, but in order to make sure that they have time to
> handle all their clients' requests for supported software, they have had
> to tighten their policy and they aren't allowed to even help me a teensy
> bit when I'm using unsupported software.
>
> Frustrating as heck. Anyway, if anyone here has any suggestions as what
> to try next, I would appreciate it. I can't recompile apache but I can
> change the config files. I can however run a script to find out the
> version of Apache I'm using, and here it is:
>
> Server version: Apache/1.3.1.1 SSL/1.15 PHP/3.0.3
> Server built: Jun 3 1999 11:15:00
> Standalone Configuration
>
> I don't want to have to learn perl and I really don't want to do my
> scripting in C++. So if anyone here has any suggestions, I'd greatly
> appreciate it.
>
> Thanks,
> -Fred
>
>
> --------
> Michael "Fred" Fredericks
> PhD Student, Computer Science
> University of Maryland College Park
> fred.at.cs.dot.umd.dot.edu ---- note I never check my dejanews mail.
>
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
Difficulty configuring web server for Python [ In reply to ]
On Mon, Aug 16, 1999 at 02:44:56PM +0000, mbf2y@my-deja.com wrote:

> I built a simple CGI script and kept getting error 500, so I simplified
> to the below script:

> #!/usr/home/campusch/usr/local/bin/python

Does your webserver do something like chroot() ? If so, is this the correct
path according to the webserver ?

> print "Content-type: text/html"
> print
> print "<HTML><BODY><H1>Hello World!</H1></BODY></HTML>"
> print

> 4) python itself has been chmod ugo+x so the web server process should
> be able to run it.

And all the directories below it are chmod <webserver>+x as well ?

> 5) This script has been chmod ugo+x so the web server process should be
> able to run it.

Has it also been set readable ? it needs to be readable for the webserver to
start python to interpret.

> [Sun Aug 15 21:59:31 1999] [error] (2)No such file or directory: exec of
> /usr/local/etc/httpd/cgi-bin/simp.py failed
> [Sun Aug 15 21:59:31 1999] [error] Premature end of script headers:
> /usr/local/etc/httpd/cgi-bin/simp.py

> While the "no such file or directory" threw me, this is not a file not
> found error... when I tried to run a script that really wasn't there, I
> got:

The 'no such file' probably refers to the script interpreter, not the script
itself... Is the script in unix text format, or DOS ? 'DOS text format'
means line endings are marked using '\r\n', UNIX uses just '\n's. Having the
file in DOS text would mean the webserver is looking for
'/usr/home/campusch/usr/local/bin/python^M'. You either need to run dos2unix
on those files (or dos2bsd as it's called under BSDI) or add a (sym)link
from python to python^M. (To give a hint... using the tcsh shell you do it
with

ln -s python python<control-v control-j>

in the /usr/home/campusch/usr/local/bin directory.

G'luck :)

--
Thomas Wouters <thomas@xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!
Difficulty configuring web server for Python [ In reply to ]
This sounds kind of like it my be an "iserver" setup, right ?

They do a chroot() so that the path for the python executable should be
/usr/local/bin (ie. remove /usr/home/campusch) from the front of any paths
you use when running from under the web server.

I've fallen foul of this a few times - the telnet login shell isn't at all
representative of the environment scripts actually run in. My setup has a
"virtual" command which runs its arguments in such a chroot'ed environment
to allow testing from the command line.

Nigel.
Difficulty configuring web server for Python [ In reply to ]
Argh!

When I read your message, I was saddened because everything you listed
was stuff I'd already tried... I had already found the ^M lurking in the
top line of my python script and deleted it, and I'd already assumed
that the webserver was chroot-ed and had tried changing my first line to
a different path...

problem was, I did them in the wrong order. I tried the corrected path
to python and that didn't work, so I undid that, and then I deleted the
ctrl-m and that didn't work.

After reading your post, I went to the perl script that I had downloaded
and changed it's path to the same full-path I was using and all of a
sudden the perl script bombed. So I realized what had happened (I'd
tried the fixes in the wrong order) and voila, I get my hello world.

Much much thanks for the quick replies I got to my query. I really
didn't want to have to learn that other scripting language ;-).

-Fred

---
Michael "Fred" Fredericks
PhD Student, Computer Science
University of Maryland, College Park
fred.at.cs.dot.umd.dot.edu ---- I NEVER check my Dejanews mail


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.