stupid Win-CGI getting started question

Duncan Booth duncan at rcp.co.uk
Wed Apr 14 04:43:26 EDT 1999


seitz at mail.medscape.com wrote in <7f0f0h$pfb$1 at nnrp1.dejanews.com>:

>Installed the basic Python stuff. I can run the interpreter. But not clear on
>getting it configured properly to talk CGI with my WinNT Netscape Enterprise
>server. I set a CGI folder path properly, but I get a nasty error message.
>But it's not a file-not-found, so I know it's finding the .py file. So I'm
>guessing it's not finding the executable.
>
>How should that first #! be changed for Windows users? Could that be it?
>
>Could the fact that all my Python stuff is under
>d:\program files\python\
>be part of the problem (the long folder name with a space in it)?

I tried all sorts of configuration changes to get it to run .py files directly, 
and eventually gave it up as a bad job (mostly because I didn't want to risk 
breaking the server).

The way I get CGI scripts to run with Netscape Enterprise server on NT is to 
put them in .cmd files instead of .py files. For example:

---------test.cmd----------------
@c:\Progra~1\Python\python -x "%~f0" %* & goto :EOF
import os

print "Content-type: text/html"
print
print "<HTML><HEAD><TITLE>Test</TITLE></HEAD>"
print "<body>Hello world from python.<p>"

for k in os.environ.keys():
        print k, os.environ[k], "<br>"
print "</body>"
---------end of test.cmd---------
You would need to change the path to reflect the location of your copy of 
Python, either use the 8.3 filename as above, or put the filename in quotes:
@"c:\Program Files\Python\python" -x "%~f0" %* & goto :EOF
works.

To get Bobo (now ZPublisher) working, I use a wrapper .cmd file like this:
--------------form.cmd----------------
@c:\Progra~1\Python\pythonw -x "%~f0" %* & goto :EOF
import traceback, sys
try:
        sys.path[0:0] = ["h:\\staff\\tvoc\\python"]

        import cgi_module_publisher
        cgi_module_publisher.publish_module("form")

except:
        print 'Content-type: text/plain\n\n'
        print 'An error occured in attempting to set up the environment for 
this application.'
-------------end of form.cmd-------------------

sys.path needs to be set to include the directory with the python code you want 
to publish, but the python code need not be visible to the web users.

I then set up a redirect in the Netscape server configuration so that an 
ordinary URL with an html extension gets redirected to form.cmd and the end 
user doesn't even need to know that any CGI is involved.

-- 
Duncan Booth                                    duncan at dales.rmplc.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
http://dales.rmplc.co.uk/Duncan




More information about the Python-list mailing list