[Tutor] Unsure why won't work
Jeff Shannon
jeff@ccvcorp.com
Thu Jul 31 16:03:01 2003
Elizabeth Bernert wrote:
> Sorry, I forgot to mention that I am attemping to run tail.py through
> Apache on Win XP.
Ah, a fairly significant little detail, there. ;) I really haven't
played around with CGI or Apache, so I don't know how much I can help
here. I'm forwarding this back to the list so that others who know more
about this sort of thing may be able to offer suggestions. I do have a
few thoughts, however...
> The only way I know to get programtitle.py programs working is to
> open IE (running IE 6.0.*) and type
> http://localhost:8080/cgi-bin/programtitle.py in the address bar.
> Attempting to run tail.py by the command line gives me a syntax error,
> where trying in IE gives me a HTTP 500 and the error log said that the
> file was UTL (unable to locate) when I used your example on my programs.
Well, if you're getting a syntax error at the command line, then even if
Apache *could* locate the file it wouldn't work. Post a complete
traceback of the syntax error, and we can probably get that sorted out
fairly quickly.
At the same time, this program is not designed to work with CGI. You
typically cannot just dump a normal program into cgi-bin and have it
work -- if nothing else, the program needs to output the correct cgi
headers in order to work with HTTP. Also, due to the limitations of
HTTP, it's difficult to write a constantly-updating program -- the
protocol works on a file-based basis. A web browser requests a file,
and typically cannot (properly) display the file until the entire
contents have arrived. Since this program is continually sending new
output, you never send an entire "file" ... so even if a browser is able
to show a response, you'll have a single page which is constantly
growing, which is probably not the preferred way of doing this. You
could perhaps have the program write a single-page snapshot of the file
and include a meta-refresh tag, which would tell the browser to reload
the file (thus grabbing a new snapshot) after a few seconds.
> I know that the program works on a mac, as is, but I don't know the
> difference and aside from path names which differ from comupter to
> computer I have been unable to find differences, except sometimes
> things work and sometimes they don't.
If you're getting a syntax error, then I'm surprised that it works as-is
on a Mac -- Python syntax is the same everywhere. One possibility is
that line-endings didn't get converted -- different OSs use different
ways to indicate the end of a line (*nix uses <LF>, Mac uses <CR>, and
Windows uses <CR><LF>), and things can get confused if you have the
wrong type of line ending.
Jeff Shannon
Technician/Programmer
Credit International