Running cgi-scripts on my home Apache server

Alex Martelli aleaxit at yahoo.com
Wed Jan 10 05:37:23 EST 2001


"Sheila King" <sheila at thinkspot.net> wrote in message
news:j92o5t4gde98rlaca47mdglnsdc7uruo3c at 4ax.com...
    [snip]
> I put a script pytestscript.py in my cgi-bin and typed:
>
> http://127.0.0.1/cgi-bin/pytestscript.py
>
> I get a 500 Internal Server error, and the error logs state:
> "(2)No such file or directory: couldn't spawn child process:
> e:/apache/cgi-bin/pytestscript.py"

The "e:/" start suggests that some Windows system is in play
(and similarly your later mention of Dos's PATH).


Coming to the first line of your script, we see:

> #! /usr/bin/python

But, *IS* the executable to be used to interpret this file
actually named 'python' (not sure if this would work for
'python.exe') AND located in the /usr/bin directory of the
current drive?  This seems somewhat unlikely for a typical
Windows-ish installation.


> I've run the script successfully on my website. It's here:
> http://www.thinkspot.net/cgi-bin/pytestscript.py
>
> so I know the script works. My host is running Linux/Apache.

As it's running Linux, it may well have the executable
named 'python' and residing in '/usr/bin' (no "current
drive" issues under Unix-ish systems).

If, on your machine, the executable interpreter is actually
in, e.g., C:\Python20\Python.Exe, try changing the first line:

#! c:/Python20/Python.Exe -u

(the -u part is not mandatory, but, by unbuffering I/O, it
can help with a CGI script).


This is what Xitami wants, for example (I don't have an
Apache installation under Windows to try, currently).


I suspect, given Apache's power, that you can configure
it to ignore your script's mendacious first line and
actually go look for Python.Exe where it should, but I
wouldn't know where to start.  A truthful first-line may
be a simpler approach if it's not too much of a problem
to have scripts be different depending on the interpreter's
actual location and name.


Alex






More information about the Python-list mailing list